Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

reconnect channels when the socket resets

  • Loading branch information...
commit ea0463f31db3d548c4fead4dcc8ce7c1ff9df832 1 parent eb12a87
bitmage authored

Showing 1 changed file with 12 additions and 2 deletions. Show diff stats Hide diff stats

  1. +12 2 lib/Client.coffee
14 lib/Client.coffee
@@ -10,9 +10,19 @@ client =
10 10 start: ->
11 11 @channels = {}
12 12
13   - channel: (name) ->
  13 + channel: (name) ->
14 14 @channels[name] ?= new Channel name, @ssocket
15 15
  16 + # if we just got a new socket, reconnect the channels
  17 + connect: (socket) ->
  18 + reconnectChannels = =>
  19 + for name, channel of @channels
  20 + @channels[name] = new Channel name, socket
  21 + @channels[name].listeners = channel.listeners
  22 + @channels[name].events = channel.events
  23 +
  24 + setTimeout reconnectChannels, 100
  25 +
16 26 validate: (socket, msg, done) ->
17 27 return done false unless typeof msg is 'object'
18 28 return done false unless typeof msg.type is 'string'
@@ -42,4 +52,4 @@ client =
42 52 if isBrowser
43 53 window.Pulsar = createClient: ProtoSock.createClientWrapper client
44 54 else
45   - module.exports = client
  55 + module.exports = client

0 comments on commit ea0463f

Please sign in to comment.
Something went wrong with that request. Please try again.