From be66978479ec0b33a595150effbc6458cb6029ae Mon Sep 17 00:00:00 2001 From: claudemiro Date: Tue, 13 Jan 2015 00:38:48 -0300 Subject: [PATCH] Changed the data field from Client WebHook The value correct is the value associated with the event, not the data attached to the subscription. --- conn.go | 2 +- webhooks.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/conn.go b/conn.go index 0d3c9da..0d05eef 100644 --- a/conn.go +++ b/conn.go @@ -208,7 +208,7 @@ func (c *Channel) Publish(a *App, event RawEvent, ignore string) error { } else { // Webhook if strings.HasPrefix(event.Event, "client-") { - a.TriggerClientEventHook(c, subs, event.Event) + a.TriggerClientEventHook(c, subs, event.Event, v) } } } diff --git a/webhooks.go b/webhooks.go index cd00ae1..eecf280 100644 --- a/webhooks.go +++ b/webhooks.go @@ -39,12 +39,12 @@ type WebHook struct { } type HookEvent struct { - Name string `json:"name"` - Channel string `json:"channel"` - Event string `json:"event,omitempty"` - Data string `json:"data,omitempty"` - SocketID string `json:"socket_id,omitempty"` - UserId string `json:"user_id,omitempty"` + Name string `json:"name"` + Channel string `json:"channel"` + Event string `json:"event,omitempty"` + Data interface{} `json:"data,omitempty"` + SocketID string `json:"socket_id,omitempty"` + UserId string `json:"user_id,omitempty"` } func NewChannelOcuppiedHook(channel *Channel) HookEvent { @@ -63,8 +63,8 @@ func NewMemberRemovedHook(channel *Channel, s *Subscriber) HookEvent { return HookEvent{Name: "member_removed", Channel: channel.ChannelID, UserId: s.Id} } -func NewClientHook(channel *Channel, s *Subscription, event string) HookEvent { - return HookEvent{Name: "client_event", Channel: channel.ChannelID, Event: event, Data: s.Data, SocketID: s.Subscriber.SocketID, UserId: s.Subscriber.Id} +func NewClientHook(channel *Channel, s *Subscription, event string, data interface{}) HookEvent { + return HookEvent{Name: "client_event", Channel: channel.ChannelID, Event: event, Data: data, SocketID: s.Subscriber.SocketID, UserId: s.Subscriber.Id} } // channel_occupied @@ -89,8 +89,8 @@ func (a *App) TriggerChannelVacatedHook(c *Channel) { // "socket_id": "socket_id of the sending socket", // "user_id": "user_id associated with the sending socket" # Only for presence channels // } -func (a *App) TriggerClientEventHook(c *Channel, s *Subscription, client_event string) { - event := NewClientHook(c, s, client_event) +func (a *App) TriggerClientEventHook(c *Channel, s *Subscription, client_event string, data interface{}) { + event := NewClientHook(c, s, client_event, data) triggerHook(event.Name, a, c, event) }