Potential solution for getting the calling window of a bound method.

This commit is contained in:
Lea Anthony
2024-04-25 17:01:22 +10:00
parent 5d0a58cc6a
commit c76b88b7b2
6 changed files with 34 additions and 40 deletions
@@ -79,6 +79,7 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
}
ctx, cancel := context.WithCancel(context.WithoutCancel(r.Context()))
ctx = context.WithValue(ctx, "window", window)
ambigiousID := false
m.l.Lock()
@@ -104,6 +105,13 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
m.l.Unlock()
}()
// Check if the first bound method parameter is a Window interface
if len(boundMethod.Inputs) > 0 {
if boundMethod.Inputs[0].ReflectType.String() == "application.Window" {
// Prepend the options.Args with the current window
options.Args = append([]interface{}{window}, options.Args...)
}
}
result, err := boundMethod.Call(ctx, options.Args)
if err != nil {
m.callErrorCallback(window, "Error calling method: %s", callID, err)