Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions code/components/voip-server-mumble/src/ChannelListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ void ChannelListener::removeListenerImpl(unsigned int userSession, int channelID
m_listenedChannels[channelID].erase(userSession);
}

void ChannelListener::removeAllListenersForUserImpl(unsigned int userSession)
{
std::unique_lock lock(m_listenerLock);

auto it = m_listeningUsers.find(userSession);
if (it != m_listeningUsers.end())
{
for (int channelID : it->second)
{
m_listenedChannels[channelID].erase(userSession);
}

m_listeningUsers.erase(it);
}
}

bool ChannelListener::isListeningImpl(unsigned int userSession, int channelID) const
{
std::shared_lock lock(m_listenerLock);
Expand Down Expand Up @@ -152,6 +168,16 @@ void ChannelListener::removeListener(const User* user, const Channel* channel)
get().removeListenerImpl(user->sessionId, channel->id);
}

void ChannelListener::removeAllListenersForUser(unsigned int userSession)
{
get().removeAllListenersForUserImpl(userSession);
}

void ChannelListener::removeAllListenersForUser(const User* user)
{
get().removeAllListenersForUserImpl(user->sessionId);
}

bool ChannelListener::isListening(unsigned int userSession, int channelID)
{
return get().isListeningImpl(userSession, channelID);
Expand Down
15 changes: 15 additions & 0 deletions code/components/voip-server-mumble/src/ChannelListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class ChannelListener
/// @param channelID The ID of the channel
void removeListenerImpl(unsigned int userSession, int channelID);

/// Removes all listeners for the given user.
///
/// @param userSession The session ID of the user
void removeAllListenersForUserImpl(unsigned int userSession);

/// @param userSession The session ID of the user
/// @param channelID The ID of the channel
/// @returns Whether the given user is listening to the given channel
Expand Down Expand Up @@ -109,6 +114,16 @@ class ChannelListener
/// @param channelID The ID of the channel
static void removeListener(const User* user, const Channel* channel);

/// Removes all listeners for the given user.
///
/// @param userSession The session ID of the user
static void removeAllListenersForUser(unsigned int userSession);

/// Removes all listeners for the given user.
///
/// @param user A pointer to the user object
static void removeAllListenersForUser(const User* user);

/// @param userSession The session ID of the user
/// @param channelID The ID of the channel
/// @returns Whether the given user is listening to the given channel
Expand Down
1 change: 1 addition & 0 deletions code/components/voip-server-mumble/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ void Client_free(client_t *client)
Client_codec_free(client);
Voicetarget_free_all(client);
Client_token_free(client);
ChannelListener::removeAllListenersForUser(client->sessionId);

list_del(&client->node);
/*if (client->ssl)
Expand Down
Loading