public void SendIntoChat(string _playerName) { chatter = new Chatter(id, _playerName); foreach (Client _client in Server.clients.Values) { if (_client.chatter != null) { if (_client.id != id) { ServerSend.AddChatter(id, _client.chatter); } } } foreach (Client _client in Server.clients.Values) { if (_client.chatter != null) { ServerSend.AddChatter(_client.id, chatter); } } ServerSend.ServerChatMessage(id, $"{_playerName} joined the chat."); }
public static void AddChatter(int _toClient, Chatter _chatter) { using (Packet _packet = new Packet((int)ServerPackets.addChatter)) { _packet.Write(_chatter.id); _packet.Write(_chatter.username); SendTCPData(_toClient, _packet); } }
public void Disconnect() { Console.WriteLine($"{tcp.socket.Client.RemoteEndPoint} has disconnected."); string _username = chatter.username; ThreadManager.ExecuteOnMainThread(() => { chatter = null; }); tcp.Disconnect(); udp.Disconnect(); ServerSend.ChatterDisconnected(id); ServerSend.ServerChatMessage($"{_username} disconnected from chat."); }