private void RecieveMessagePackets() { byte[] bytes = ReadData(sizeof(int), _networkStream); int numMessages = BitConverter.ToInt32(bytes, 0); for (int i = 0; i < numMessages; i++) { bytes = ReadData(sizeof(int), _networkStream); int messageSize = BitConverter.ToInt32(bytes, 0); bytes = ReadData(messageSize, _networkStream); MessagePacket packet = MessagePacket.FromBytes(bytes); GUI.MessagePanel.Instance.AddMessage(packet); } }
private void RecieveMessagePackets() { byte[] bytes = ReadData(sizeof(int), _networkStream); int numMessages = BitConverter.ToInt32(bytes, 0); for (int i = 0; i < numMessages; i++) { bytes = ReadData(sizeof(int), _networkStream); int messageSize = BitConverter.ToInt32(bytes, 0); bytes = ReadData(messageSize, _networkStream); MessagePacket packet = MessagePacket.FromBytes(bytes); packet.Message = _mapPlayer.Username + ": " + packet.Message; // the server signs the messages with the username packet.PlayerID = _mapPlayer.PlayerID; Server.Instance.SendMessage(packet); } }