[runtime] Add cancelation of bound method calls and context passing

This commit is contained in:
stffabi
2024-03-04 10:34:14 +01:00
parent 7e687750b2
commit bfe9a9d015
25 changed files with 319 additions and 124 deletions
+10 -1
View File
@@ -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)
}