mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[runtime] Add cancelation of bound method calls and context passing
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// TODO maybe we could use a new struct that has the targetWindow as an attribute so we could get rid of passing the targetWindow
|
||||
@@ -22,16 +24,21 @@ const (
|
||||
screensRequest = 7
|
||||
systemRequest = 8
|
||||
browserRequest = 9
|
||||
cancelCallRequesst = 10
|
||||
)
|
||||
|
||||
type MessageProcessor struct {
|
||||
pluginManager *PluginManager
|
||||
logger *slog.Logger
|
||||
|
||||
runningCalls map[string]context.CancelFunc
|
||||
l sync.Mutex
|
||||
}
|
||||
|
||||
func NewMessageProcessor(logger *slog.Logger) *MessageProcessor {
|
||||
return &MessageProcessor{
|
||||
logger: logger,
|
||||
logger: logger,
|
||||
runningCalls: map[string]context.CancelFunc{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +123,8 @@ func (m *MessageProcessor) HandleRuntimeCallWithIDs(rw http.ResponseWriter, r *h
|
||||
m.processSystemMethod(method, rw, r, targetWindow, params)
|
||||
case browserRequest:
|
||||
m.processBrowserMethod(method, rw, r, targetWindow, params)
|
||||
case cancelCallRequesst:
|
||||
m.processCallCancelMethod(method, rw, r, targetWindow, params)
|
||||
default:
|
||||
m.httpError(rw, "Unknown runtime call: %d", object)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user