removeListener method
Removes a listener from a named channel.
Implementation
void removeListener(Session session, String channelName,
MessageCentralListenerCallback listener) {
var channel = _channels[channelName];
if (channel != null) {
channel.remove(listener);
if (channel.isEmpty) {
_channels.remove(channelName);
if (session.serverpod.redisController != null) {
session.serverpod.redisController!.unsubscribe(channelName);
}
}
}
var subscribedChannels = _sessionToChannelNamesLookup[session];
if (subscribedChannels != null) {
subscribedChannels.remove(channelName);
if (subscribedChannels.isEmpty) {
_sessionToChannelNamesLookup.remove(session);
}
}
var callbacks = _sessionToCallbacksLookup[session];
if (callbacks != null) {
callbacks.remove(listener);
if (callbacks.isEmpty) {
_sessionToCallbacksLookup.remove(session);
}
}
}