Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dist/stomp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/stomp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class Client
# (value in ms)
incoming: 10000
}
# Send pings 10% faster and allow pongs 10% slower to account for
# inaccurate timing in the web browser
@heartbeatWindow = 0.10 #10%
# subscription callbacks indexed by subscriber's ID
@subscriptions = {}

Expand All @@ -129,6 +132,7 @@ class Client

unless @heartbeat.outgoing == 0 or serverIncoming == 0
ttl = Math.max(@heartbeat.outgoing, serverIncoming)
ttl = ttl - (ttl * @heartbeatWindow);
@debug? "send PING every #{ttl}ms"
@pinger = window?.setInterval(=>
@ws.send Byte.LF
Expand All @@ -137,6 +141,7 @@ class Client

unless @heartbeat.incoming == 0 or serverOutgoing == 0
ttl = Math.max(@heartbeat.incoming, serverOutgoing)
ttl = ttl + (ttl * @heartbeatWindow)
@debug? "check PONG every #{ttl}ms"
@ponger = window?.setInterval(=>
delta = Date.now() - @serverActivity
Expand Down Expand Up @@ -355,4 +360,4 @@ else if exports?
Stomp.WebSocketClass = require('./test/server.mock.js').StompServerMock
# or in the current object (e.g. a WebWorker)
else
self.Stomp = Stomp
self.Stomp = Stomp