mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
stuff values into context
This commit is contained in:
@@ -24,7 +24,7 @@ type UDPMulticast struct {
|
||||
func init() {
|
||||
RegisterModule(ModuleRegistration{
|
||||
Type: "net.udp.multicast",
|
||||
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
|
||||
ip, ok := params["ip"]
|
||||
|
||||
@@ -53,6 +53,12 @@ func init() {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
router, ok := ctx.Value(route.RouterContextKey).(route.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("net.udp.multicast unable to get router from context")
|
||||
}
|
||||
return &UDPMulticast{config: config, Addr: addr, ctx: ctx, router: router, logger: CreateLogger(config)}, nil
|
||||
},
|
||||
})
|
||||
@@ -108,7 +114,7 @@ func (um *UDPMulticast) Run() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (um *UDPMulticast) Output(payload any) error {
|
||||
func (um *UDPMulticast) Output(ctx context.Context, payload any) error {
|
||||
|
||||
payloadBytes, ok := payload.([]byte)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user