Fix send error messages in wsProxy.
This commit is contained in:
parent
65daa23a74
commit
e4486f4c17
@ -16,11 +16,15 @@ export default function wsProxy (client, url, opts) {
|
|||||||
const autoClose = !!opts.autoClose
|
const autoClose = !!opts.autoClose
|
||||||
delete opts.autoClose
|
delete opts.autoClose
|
||||||
|
|
||||||
function onClientSendError (error) {
|
function onClientSend (error) {
|
||||||
debug('client send error', error)
|
if (error) {
|
||||||
|
debug('client send error', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function onRemoteSendError (error) {
|
function onRemoteSend (error) {
|
||||||
debug('remote send error', error)
|
if (error) {
|
||||||
|
debug('remote send error', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const remote = new WebSocket(url, opts).once('open', function () {
|
const remote = new WebSocket(url, opts).once('open', function () {
|
||||||
@ -34,13 +38,13 @@ export default function wsProxy (client, url, opts) {
|
|||||||
}).once('error', function (error) {
|
}).once('error', function (error) {
|
||||||
debug('remote error: %s', error)
|
debug('remote error: %s', error)
|
||||||
}).on('message', function (message) {
|
}).on('message', function (message) {
|
||||||
client.send(message, onClientSendError)
|
client.send(message, onClientSend)
|
||||||
})
|
})
|
||||||
|
|
||||||
client.once('close', function () {
|
client.once('close', function () {
|
||||||
debug('client closed')
|
debug('client closed')
|
||||||
remote.close()
|
remote.close()
|
||||||
}).on('message', function (message) {
|
}).on('message', function (message) {
|
||||||
remote.send(message, onRemoteSendError)
|
remote.send(message, onRemoteSend)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user