This commit is contained in:
2025-05-26 14:32:43 +02:00
parent 81741d20c1
commit 9cbf5b1cde
6 changed files with 206 additions and 0 deletions

View File

@ -41,6 +41,7 @@ func OnMessage[T any](ctx context.Context, client *Client, mType string) (chan T
type Broadcast struct {
Name string `mapstructure:"name" json:"name"`
Payload any `mapstructure:"payload" json:"payload"`
State string `mapstructure:"state" json:"state"`
}
// OnBroadcast listens for ReachView "broadcast" messages
@ -52,3 +53,13 @@ func OnBroadcast(ctx context.Context, client *Client) (chan Broadcast, error) {
return ch, nil
}
// OnMessageType listens for ReachView type of messages
func OnMessageType(ctx context.Context, client *Client, messageType string) (chan Broadcast, error) {
ch, err := OnMessage[Broadcast](ctx, client, messageType)
if err != nil {
return nil, errors.WithStack(err)
}
return ch, nil
}