More robust websocket writting

master
Jesús Espino 2017-04-06 14:39:18 +02:00
parent c4a95a3de9
commit cb380d5cbc
2 changed files with 8 additions and 2 deletions

View File

@ -44,7 +44,10 @@ class Client
@.subscriptionManager.remove(routing_key) @.subscriptionManager.remove(routing_key)
sendPong: -> sendPong: ->
@ws.send(JSON.stringify({cmd: "pong"})) try
@ws.send(JSON.stringify({cmd: "pong"}))
catch e
console.error("Error: ", e)
close: () -> close: () ->
if @.subscriptionManager if @.subscriptionManager

View File

@ -14,7 +14,10 @@ class Subscription
clientMsg.routing_key = msg.fields.routingKey clientMsg.routing_key = msg.fields.routingKey
clientMsgStr = JSON.stringify(clientMsg) clientMsgStr = JSON.stringify(clientMsg)
@ws.send clientMsgStr try
@ws.send clientMsgStr
catch e
console.error("Error: ", e)
start: () -> start: () ->
queue.subscribe(@client_id, @routing_key, @.handleMessage.bind(@)) queue.subscribe(@client_id, @routing_key, @.handleMessage.bind(@))