Add IPID to global messages when user is authenticated
This adds the ability to send altered packets to a specific group of users and the original to everyone else.
This commit is contained in:
parent
30b769b282
commit
7dbbf41d33
@ -75,6 +75,14 @@ class Server : public QObject {
|
|||||||
*/
|
*/
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enum to specifc different targets to send altered packets to a specific usergroup.
|
||||||
|
*/
|
||||||
|
enum class TARGET_TYPE {
|
||||||
|
AUTHENTICATED
|
||||||
|
};
|
||||||
|
Q_ENUM(TARGET_TYPE)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets a pointer to a client by IPID.
|
* @brief Gets a pointer to a client by IPID.
|
||||||
*
|
*
|
||||||
@ -129,6 +137,14 @@ class Server : public QObject {
|
|||||||
*/
|
*/
|
||||||
void broadcast(AOPacket packet);
|
void broadcast(AOPacket packet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sends a packet to clients, sends an altered packet to a specific usergroup.
|
||||||
|
* @param The packet to send to the clients.
|
||||||
|
* @param The altered packet to send to the other clients.
|
||||||
|
* @param tENUM to determine the targets of the altered packet.
|
||||||
|
*/
|
||||||
|
void broadcast(AOPacket packet, AOPacket other_packet, enum TARGET_TYPE target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the character's character ID (= their index in the character list).
|
* @brief Returns the character's character ID (= their index in the character list).
|
||||||
*
|
*
|
||||||
|
@ -71,10 +71,9 @@ void AOClient::cmdG(int argc, QStringList argv)
|
|||||||
QString l_sender_name = m_ooc_name;
|
QString l_sender_name = m_ooc_name;
|
||||||
QString l_sender_area = server->m_area_names.value(m_current_area);
|
QString l_sender_area = server->m_area_names.value(m_current_area);
|
||||||
QString l_sender_message = argv.join(" ");
|
QString l_sender_message = argv.join(" ");
|
||||||
for (AOClient* l_client : qAsConst(server->m_clients)) {
|
AOPacket l_packet = AOPacket("CT", {"[G][" + m_ipid + "][" + l_sender_area + "]" + l_sender_name, l_sender_message});
|
||||||
if (l_client->m_global_enabled)
|
AOPacket l_other_packet = AOPacket("CT", {"[G][" + l_sender_area + "]" + l_sender_name, l_sender_message});
|
||||||
l_client->sendPacket("CT", {"[G][" + l_sender_area + "]" + l_sender_name, l_sender_message});
|
server->broadcast(l_packet, l_other_packet, Server::TARGET_TYPE::AUTHENTICATED);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +215,21 @@ void Server::broadcast(AOPacket packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::broadcast(AOPacket packet, AOPacket other_packet, TARGET_TYPE target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case TARGET_TYPE::AUTHENTICATED:
|
||||||
|
for (AOClient* client : qAsConst(m_clients)){
|
||||||
|
if (client->m_authenticated) {
|
||||||
|
client->sendPacket(other_packet);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
client->sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<AOClient*> Server::getClientsByIpid(QString ipid)
|
QList<AOClient*> Server::getClientsByIpid(QString ipid)
|
||||||
{
|
{
|
||||||
QList<AOClient*> return_clients;
|
QList<AOClient*> return_clients;
|
||||||
|
Loading…
Reference in New Issue
Block a user