Triggering Presence channels events.

This commit is contained in:
claudemiro
2015-01-14 13:19:11 -03:00
parent 5695bb445d
commit 5043b05c7b
7 changed files with 126 additions and 72 deletions
+2 -4
View File
@@ -131,7 +131,6 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses
}
expectedAuthKey := fmt.Sprintf("%s:%s", app.Key, utils.HashMAC([]byte(strings.Join(toSign, ":")), []byte(app.Secret)))
if subscribeEvent.Data.Auth != expectedAuthKey {
emitWSError(NewGenericError(fmt.Sprintf("Auth value for subscription to %s is invalid", channelName)), conn)
continue
@@ -139,11 +138,10 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses
}
channel := app.FindOrCreateChannelByChannelID(channelName)
app.Subscribe(channel, subscriber, subscribeEvent.Data.ChannelData)
log.Info(subscribeEvent.Data.ChannelData)
if err := conn.WriteJSON(NewSubscriptionSucceededEvent(channel.ChannelID, "{}")); err != nil {
if err := app.Subscribe(channel, subscriber, subscribeEvent.Data.ChannelData); err != nil {
emitWSError(NewGenericReconnectImmediatelyError(), conn)
break
}
case "pusher:unsubscribe":
unsubscribeEvent := UnsubscribeEvent{}