Added SLAddClient / SLRemoveClient messages (#30)

This commit is contained in:
Bruce Sheplan
2020-06-10 08:05:32 -05:00
committed by GitHub
parent 71c606cb94
commit b2439cd90c
6 changed files with 94 additions and 0 deletions

View File

@ -286,6 +286,16 @@ class UnitConnection extends EventEmitter {
this.client.write(new messages.SLCancelDelay().toBuffer());
}
addClient(senderId) {
debugUnit('sending add client command...');
this.client.write(new messages.SLAddClient(senderId).toBuffer());
}
removeClient(senderId) {
debugUnit('sending remove client command...');
this.client.write(new messages.SLRemoveClient(senderId).toBuffer());
}
onClientMessage(msg) {
debugUnit('received message of length %d', msg.length);
if (msg.length < 4) {
@ -379,6 +389,18 @@ class UnitConnection extends EventEmitter {
debugUnit(" it's a cancel delay ack");
this.emit('cancelDelay', new messages.SLCancelDelay());
break;
case messages.SLAddClient.getResponseId():
debugUnit(" it's an add client ack");
this.emit('addClient', new messages.SLCancelDelay());
break;
case messages.SLRemoveClient.getResponseId():
debugUnit(" it's a remove client ack");
this.emit('removeClient', new messages.SLCancelDelay());
break;
case messages.SLPoolStatusMessage.getAsyncResponseId():
debugUnit(" it's async pool status");
this.emit('poolStatus', new messages.SLPoolStatusMessage(msg));
break;
case 13:
debugUnit(" it's a login failure.");
this.emit('loginFailed');