private void SendChatMessage(ClientSession session, string message, bool sendToSelf = true) { if (message.StartsWith("/")) { string[] args = message.Substring(1).Split(' '); if (!PlatformRacing3Server.CommandManager.Execte(session, args[0], args.AsSpan().Slice(1, args.Length - 1))) { session.SendPacket(new AlertOutgoingMessage("Unknown command")); } } else { ChatOutgoingMessage packet = new ChatOutgoingMessage(this.Name, message, session.SocketId, session.UserData.Id, session.UserData.Username, session.UserData.NameColor); this.RecentMessages.Enqueue(packet); while (this.RecentMessages.Count > ChatRoom.MAX_RECENT_MESSAGES) { this.RecentMessages.TryDequeue(out _); } if (sendToSelf) { this.Clients.SendPacket(packet); } else { this.Clients.SendPacket(packet, session); } } }
private void SendChatMessage(ClientSession session, string message, bool sendToSelf = true) { ChatOutgoingMessage packet = new ChatOutgoingMessage(this.Name, message, session.SocketId, session.UserData.Id, session.UserData.Username, session.UserData.NameColor); if (sendToSelf) { this.Clients.SendPacket(packet); } else { this.Clients.SendPacket(packet, session); } }