diff --git a/core/include/area_data.h b/core/include/area_data.h index a8512ba..24959de 100644 --- a/core/include/area_data.h +++ b/core/include/area_data.h @@ -870,6 +870,25 @@ public slots: */ void sendAreaPacket(AOPacket f_packet, int f_area_index); + /** + * @brief sendAreaPacketClient Sends a packet to the specified client. + * + * @param f_packet The packe to be send. + * + * @param f_user_id The user ID of the client. + */ + void sendAreaPacketClient(AOPacket f_packet, int f_user_id); + + /** + * @brief userJoinedArea Signals that a new client has joined an area. + * + * @details This is mostly a signal for more compelex features where multiple managers need to know of the change. + * + * @param f_area_index Area Index that the client joined in. + * + * + * @param f_user_id The user ID of the client. + */ void userJoinedArea(int f_area_index, int f_user_id); private: diff --git a/core/src/area_data.cpp b/core/src/area_data.cpp index ea0b04b..8fbcf6d 100644 --- a/core/src/area_data.cpp +++ b/core/src/area_data.cpp @@ -95,6 +95,7 @@ void AreaData::clientJoinedArea(int f_charId, int f_userId) } m_joined_ids.append(f_userId); emit userJoinedArea(m_index, f_userId); + emit sendAreaPacketClient(AOPacket("MC",{m_currentMusic, QString::number(-1)}), f_userId); } QList AreaData::owners() const diff --git a/core/src/server.cpp b/core/src/server.cpp index aacaec1..4996b88 100644 --- a/core/src/server.cpp +++ b/core/src/server.cpp @@ -104,6 +104,8 @@ void Server::start() m_areas.insert(i, l_area); connect(l_area, &AreaData::sendAreaPacket, this, QOverload::of(&Server::broadcast)); + connect(l_area, &AreaData::sendAreaPacketClient, + this, &Server::unicast); connect(l_area, &AreaData::userJoinedArea, music_manager, &MusicManager::userJoinedArea); music_manager->registerArea(i);