Changed the data field from Client WebHook

The value correct is the value associated with the event, not the data
attached to the subscription.
This commit is contained in:
claudemiro
2015-01-13 00:38:48 -03:00
parent c125bc7206
commit be66978479
2 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -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)
}
}
}
+10 -10
View File
@@ -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)
}