Skip to content

Commit

Permalink
setup heart-beat whenever the CONNECTED frame is received whether the…
Browse files Browse the repository at this point in the history
…re is a connectCallback
  • Loading branch information
jmesnil committed Nov 24, 2012
1 parent 8e6536c commit f0c4a57
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
28 changes: 19 additions & 9 deletions dist/stomp.js

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

2 changes: 1 addition & 1 deletion dist/stomp.min.js

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

13 changes: 7 additions & 6 deletions src/stomp.coffee
Expand Up @@ -171,7 +171,7 @@ class Client
# We wait twice the TTL to be flexible on window's setInterval calls
if delta > ttl * 2
@debug? "did not receive server activity for the last #{delta}ms"
@_cleanUp()
@_cleanUp()
, ttl)

# [CONNECT Frame](http://stomp.github.com/stomp-specification-1.1.html#CONNECT_or_STOMP_Frame)
Expand Down Expand Up @@ -200,15 +200,16 @@ class Client
# Handle STOMP frames received from the server
for frame in Frame.unmarshall(data)
# [CONNECTED Frame](http://stomp.github.com/stomp-specification-1.1.html#CONNECTED_Frame)
if frame.command is "CONNECTED" and connectCallback
if frame.command is "CONNECTED"
@debug? "connected to server #{frame.headers.server}"
@connected = true
@_setupHeartbeat(frame.headers)
connectCallback(frame)
@connectCallback? frame
# [MESSAGE Frame](http://stomp.github.com/stomp-specification-1.1.html#MESSAGE)
else if frame.command is "MESSAGE"
# the `onreceive` callback is registered when the client calls `subscribe()`
onreceive = @subscriptions[frame.headers.subscription]
onreceive?(frame)
onreceive? frame
# [RECEIPT Frame](http://stomp.github.com/stomp-specification-1.1.html#RECEIPT)
#
# The client instance can set its `onreceipt` field to a function taking
Expand Down Expand Up @@ -261,8 +262,8 @@ class Client
# [SEND Frame](http://stomp.github.com/stomp-specification-1.1.html#SEND)
send: (destination, headers={}, body='') ->
headers.destination = destination
@_transmit "SEND", headers, body
@_transmit "SEND", headers, body

# [SUBSCRIBE Frame](http://stomp.github.com/stomp-specification-1.1.html#SUBSCRIBE)
subscribe: (destination, callback, headers={}) ->
if typeof(headers.id) == 'undefined' || headers.id.length == 0
Expand Down

0 comments on commit f0c4a57

Please sign in to comment.