From e4486f4c175353f4a204fe7d3f57216cbc573985 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 19 May 2015 12:31:14 +0200 Subject: [PATCH] Fix send error messages in wsProxy. --- src/ws-proxy.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ws-proxy.js b/src/ws-proxy.js index 9610830d7..f09fcb724 100644 --- a/src/ws-proxy.js +++ b/src/ws-proxy.js @@ -16,11 +16,15 @@ export default function wsProxy (client, url, opts) { const autoClose = !!opts.autoClose delete opts.autoClose - function onClientSendError (error) { - debug('client send error', error) + function onClientSend (error) { + if (error) { + debug('client send error', error) + } } - function onRemoteSendError (error) { - debug('remote send error', error) + function onRemoteSend (error) { + if (error) { + debug('remote send error', error) + } } const remote = new WebSocket(url, opts).once('open', function () { @@ -34,13 +38,13 @@ export default function wsProxy (client, url, opts) { }).once('error', function (error) { debug('remote error: %s', error) }).on('message', function (message) { - client.send(message, onClientSendError) + client.send(message, onClientSend) }) client.once('close', function () { debug('client closed') remote.close() }).on('message', function (message) { - remote.send(message, onRemoteSendError) + remote.send(message, onRemoteSend) }) }