Add: [Network] external chat messages for remote admins (#9563)

This commit is contained in:
dP
2021-09-20 00:09:06 +03:00
committed by GitHub
parent d9f8ed7bdf
commit 31cf9e888b
16 changed files with 112 additions and 5 deletions

View File

@@ -670,6 +670,28 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action,
return NETWORK_RECV_STATUS_OKAY;
}
/**
* Send a chat message from external source.
* @param source Name of the source this message came from.
* @param colour TextColour to use for the message.
* @param user Name of the user who sent the messsage.
* @param msg The actual message.
*/
NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
{
if (this->status < STATUS_PRE_ACTIVE) return NETWORK_RECV_STATUS_OKAY;
Packet *p = new Packet(PACKET_SERVER_EXTERNAL_CHAT);
p->Send_string(source);
p->Send_uint16(colour);
p->Send_string(user);
p->Send_string(msg);
this->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;
}
/**
* Tell the client another client quit with an error.
* @param client_id The client that quit.
@@ -1262,12 +1284,27 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
ci = NetworkClientInfo::GetByClientID(from_id);
if (ci != nullptr) {
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data);
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data, "");
}
break;
}
}
/**
* Send a chat message from external source.
* @param source Name of the source this message came from.
* @param colour TextColour to use for the message.
* @param user Name of the user who sent the messsage.
* @param msg The actual message.
*/
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
{
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
cs->SendExternalChat(source, colour, user, msg);
}
NetworkTextMessage(NETWORK_ACTION_EXTERNAL_CHAT, colour, false, user, msg, 0, source);
}
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p)
{
if (this->status < STATUS_PRE_ACTIVE) {