Skip to content

Commit d5056fd

Browse files
committed
fix socket.kickOut()
1 parent e3e8ab0 commit d5056fd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

serversocket.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,10 +1427,19 @@ AGServerSocket.prototype.deauthenticate = async function (options) {
14271427
};
14281428

14291429
AGServerSocket.prototype.kickOut = function (channel, message) {
1430-
delete this.channelSubscriptions[channel];
1431-
this.channelSubscriptionsCount--;
1432-
this.transmit('#kickOut', {channel, message});
1433-
return this.server.brokerEngine.unsubscribeSocket(this, channel);
1430+
let channels = channel;
1431+
if (!channels) {
1432+
channels = Object.keys(this.channelSubscriptions);
1433+
}
1434+
if (!Array.isArray(channels)) {
1435+
channels = [channel];
1436+
}
1437+
for (const channelName of channels) {
1438+
delete this.channelSubscriptions[channelName];
1439+
this.channelSubscriptionsCount--;
1440+
this.transmit('#kickOut', {channel: channelName, message});
1441+
this.server.brokerEngine.unsubscribeSocket(this, channelName);
1442+
}
14341443
};
14351444

14361445
AGServerSocket.prototype.subscriptions = function () {

0 commit comments

Comments
 (0)