mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-09 15:16:42 +02:00
assign the group's stream to clients
This commit is contained in:
parent
7c93582e07
commit
3818394cf2
1 changed files with 13 additions and 1 deletions
|
@ -105,6 +105,7 @@ void StreamServer::onDisconnect(StreamSession* streamSession)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void StreamServer::onMessageReceived(ControlSession* controlSession, const std::string& message)
|
||||
{
|
||||
JsonRequest request;
|
||||
|
@ -175,7 +176,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
|
|||
for (auto client: group->clients)
|
||||
{
|
||||
session_ptr session = getStreamSession(client->id);
|
||||
if (session != nullptr)
|
||||
if (session && (session->pcmStream() != stream))
|
||||
{
|
||||
session->sendAsync(stream->getHeader());
|
||||
session->setPcmStream(stream);
|
||||
|
@ -203,6 +204,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
|
|||
}
|
||||
|
||||
/// Add clients to group
|
||||
PcmStreamPtr stream = streamManager_->getStream(group->streamId);
|
||||
for (const auto& clientId: clients)
|
||||
{
|
||||
ClientInfoPtr client = Config::instance().getClientInfo(clientId);
|
||||
|
@ -219,6 +221,14 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
|
|||
}
|
||||
|
||||
group->addClient(client);
|
||||
|
||||
/// assign new stream
|
||||
session_ptr session = getStreamSession(client->id);
|
||||
if (session && stream && (session->pcmStream() != stream))
|
||||
{
|
||||
session->sendAsync(stream->getHeader());
|
||||
session->setPcmStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
if (group->empty())
|
||||
|
@ -268,6 +278,7 @@ void StreamServer::onMessageReceived(ControlSession* controlSession, const std::
|
|||
}
|
||||
|
||||
|
||||
|
||||
void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseMessage& baseMessage, char* buffer)
|
||||
{
|
||||
// logD << "onMessageReceived: " << baseMessage.type << ", size: " << baseMessage.size << ", id: " << baseMessage.id << ", refers: " << baseMessage.refersTo << ", sent: " << baseMessage.sent.sec << "," << baseMessage.sent.usec << ", recv: " << baseMessage.received.sec << "," << baseMessage.received.usec << "\n";
|
||||
|
@ -347,6 +358,7 @@ void StreamServer::onMessageReceived(StreamSession* connection, const msg::BaseM
|
|||
}
|
||||
|
||||
|
||||
|
||||
session_ptr StreamServer::getStreamSession(StreamSession* streamSession) const
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue