stuff values into context

This commit is contained in:
Joel Wetzell
2025-12-27 22:59:30 -06:00
parent 3458b52206
commit 8ffc7d02a5
21 changed files with 167 additions and 53 deletions

View File

@@ -35,7 +35,7 @@ type SIPCallMessage struct {
func init() {
RegisterModule(ModuleRegistration{
Type: "sip.call.server",
New: func(ctx context.Context, config config.ModuleConfig, router route.RouteIO) (Module, error) {
New: func(ctx context.Context, config config.ModuleConfig) (Module, error) {
params := config.Params
portNum := 5060
@@ -87,6 +87,12 @@ func init() {
}
userAgentString = specificTransportString
}
router, ok := ctx.Value(route.RouterContextKey).(route.RouteIO)
if !ok {
return nil, errors.New("sip.call.server unable to get router from context")
}
return &SIPCallServer{config: config, ctx: ctx, router: router, IP: ipString, Port: int(portNum), Transport: transportString, UserAgent: userAgentString, logger: CreateLogger(config)}, nil
},
})
@@ -143,7 +149,7 @@ func (scs *SIPCallServer) HandleCall(inDialog *diago.DialogServerSession) {
<-inDialog.Context().Done()
}
func (scs *SIPCallServer) Output(payload any) error {
func (scs *SIPCallServer) Output(ctx context.Context, payload any) error {
payloadMsg, ok := payload.(string)
if !ok {