Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reconnect channels when the socket resets

  • Loading branch information...
commit ea0463f31db3d548c4fead4dcc8ce7c1ff9df832 1 parent eb12a87
bitmage authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/Client.coffee
View
14 lib/Client.coffee
@@ -10,9 +10,19 @@ client =
start: ->
@channels = {}
- channel: (name) ->
+ channel: (name) ->
@channels[name] ?= new Channel name, @ssocket
+ # if we just got a new socket, reconnect the channels
+ connect: (socket) ->
+ reconnectChannels = =>
+ for name, channel of @channels
+ @channels[name] = new Channel name, socket
+ @channels[name].listeners = channel.listeners
+ @channels[name].events = channel.events
+
+ setTimeout reconnectChannels, 100
+
validate: (socket, msg, done) ->
return done false unless typeof msg is 'object'
return done false unless typeof msg.type is 'string'
@@ -42,4 +52,4 @@ client =
if isBrowser
window.Pulsar = createClient: ProtoSock.createClientWrapper client
else
- module.exports = client
+ module.exports = client
Please sign in to comment.
Something went wrong with that request. Please try again.