From bf9c1f08bcf1ea2a95362ccdce731583199d1ea3 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Thu, 25 Apr 2024 17:01:22 +1000 Subject: [PATCH] Potential solution for getting the calling window of a bound method. --- v3/pkg/application/messageprocessor_call.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/v3/pkg/application/messageprocessor_call.go b/v3/pkg/application/messageprocessor_call.go index 7e7bebcb..cd294e50 100644 --- a/v3/pkg/application/messageprocessor_call.go +++ b/v3/pkg/application/messageprocessor_call.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "net/http" - "reflect" ) const ( @@ -80,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) ambiguousID := false m.l.Lock() @@ -105,12 +105,9 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter, m.l.Unlock() }() - // Check if the first or second bound method parameter is a Window interface + // Check if the first bound method parameter is a Window interface if len(boundMethod.Inputs) > 0 { - if boundMethod.Inputs[0].ReflectType == reflect.TypeFor[Window]() { - // Prepend the options.Args with the current window - options.Args = append([]interface{}{window}, options.Args...) - } else if len(boundMethod.Inputs) > 1 && boundMethod.Inputs[1].ReflectType == reflect.TypeFor[Window]() { + if boundMethod.Inputs[0].ReflectType.String() == "application.Window" { // Prepend the options.Args with the current window options.Args = append([]interface{}{window}, options.Args...) }