Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.3 #283

Open
wants to merge 2 commits into
base: v0.3
Choose a base branch
from
Open

V0.3 #283

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
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion src/trans-websocket.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class WebSocketReceiver extends transport.GenericReceiver
try
message = JSON.parse(payload)
catch x
return @didClose(3000, 'Broken framing.')
# return raw message when not json string
message = payload
# return @didClose(3000, 'Broken framing.')
if payload[0] is '['
for msg in message
@session.didMessage(msg)
Expand Down
27 changes: 21 additions & 6 deletions src/transport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ class SockJSConnection extends stream.Stream
toString: ->
return '<SockJSConnection ' + @id + '>'

write: (string) ->
return @_session.send('' + string)
write: (data) ->
# binary buffer
if(data instanceof Buffer)
return @_session.send(data)
else
return @_session.send('' + data)

end: (string) ->
if string
Expand Down Expand Up @@ -198,7 +202,10 @@ class Session
send: (payload) ->
if @readyState isnt Transport.OPEN
return false
@send_buffer.push('' + payload)
if payload instanceof Buffer
@send_buffer.push(payload)
else
@send_buffer.push('' + payload)
if @recv
@tryFlush()
return true
Expand Down Expand Up @@ -265,9 +272,17 @@ class GenericReceiver
@session.unregister()

doSendBulk: (messages) ->
q_msgs = for m in messages
utils.quote(m)
@doSendFrame('a' + '[' + q_msgs.join(',') + ']')
q_msgs = []
for m in messages
if !(m instanceof Buffer)
q_msgs.push(utils.quote(m))
else
if q_msgs.length > 0
@doSendFrame('a' + '[' + q_msgs.join(',') + ']')
q_msgs = []
@doSendFrame(m)
if q_msgs.length > 0
@doSendFrame('a' + '[' + q_msgs.join(',') + ']')

heartbeat: ->
@doSendFrame('h')
Expand Down