source: TFP-WebServer/CommandExtensions/src/ChatHelpers.cs@ 499

Last change on this file since 499 was 499, checked in by alloc, 4 months ago

*Fixed: Chat code
*Fixed: SSE connection counting, added connection set up logging

File size: 772 bytes
Line 
1namespace CommandExtensions {
2 public static class ChatHelpers {
3 public static void SendMessage (ClientInfo _receiver, ClientInfo _sender, string _message) {
4 string senderName;
5 if (_sender != null) {
6 PrivateMessageConnections.SetLastPMSender (_sender, _receiver);
7 senderName = _sender.playerName;
8 } else {
9 senderName = "Server";
10 }
11
12 _receiver.SendPackage (NetPackageManager.GetPackage<NetPackageChat> ().Setup (EChatType.Whisper, -1,
13 $"{senderName} (PM): {_message}", null,
14 EMessageSender.None));
15 string receiverName = _receiver.playerName;
16 receiverName = receiverName != null ? $"\"{receiverName}\"" : "unknownName";
17 SdtdConsole.Instance.Output ($"Message to player {receiverName} sent with sender \"{senderName}\"");
18 }
19 }
20}
Note: See TracBrowser for help on using the repository browser.