Send empty command as keep-alive.
Fixes #36. Inspired from http://py-ts3.readthedocs.org/en/latest/_modules/ts3/query.html.develop
parent
c48ea91682
commit
92c66a6bbc
|
@ -140,6 +140,22 @@ module.exports = class TS3ClientQuery extends EventEmitter
|
||||||
else
|
else
|
||||||
@emit "vars", response.args
|
@emit "vars", response.args
|
||||||
|
|
||||||
|
# send keepalives to avoid connection timeout
|
||||||
|
@_resetKeepalive()
|
||||||
|
|
||||||
|
_sendKeepalive: (cb) =>
|
||||||
|
@_log.silly "Send: <keep-alive>"
|
||||||
|
|
||||||
|
@_tcpClient.write "\n\r", "utf8", () => cb?()
|
||||||
|
|
||||||
|
_stopKeepalive: () =>
|
||||||
|
if @_keepaliveInt is not undefined
|
||||||
|
clearInterval @_keepaliveInt
|
||||||
|
|
||||||
|
_resetKeepalive: () =>
|
||||||
|
@_stopKeepalive()
|
||||||
|
@_keepaliveInt = setInterval @_sendKeepalive, 60000
|
||||||
|
|
||||||
close: (cb) =>
|
close: (cb) =>
|
||||||
if not @_tcpClient
|
if not @_tcpClient
|
||||||
cb?()
|
cb?()
|
||||||
|
@ -165,6 +181,7 @@ module.exports = class TS3ClientQuery extends EventEmitter
|
||||||
@_log.silly "Send:", text.trim()
|
@_log.silly "Send:", text.trim()
|
||||||
|
|
||||||
@_tcpClient.write text, "utf8", () => cb?()
|
@_tcpClient.write text, "utf8", () => cb?()
|
||||||
|
@_resetKeepalive()
|
||||||
|
|
||||||
banadd: (cb) =>
|
banadd: (cb) =>
|
||||||
throw new Error "Not implemented yet"
|
throw new Error "Not implemented yet"
|
||||||
|
|
Loading…
Reference in New Issue