/// <summary> /// Handles packet from a client /// </summary> /// <param name="clientID"></param> /// <param name="type"></param> /// <param name="packet"></param> public void GetPacketFromClient(int clientID, int type, Packet packet) { byte[] bytes = packet.ReadAllBytes(); object result = null; if (bytes != null) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream(bytes)) { result = binaryFormatter.Deserialize(stream); } } Listener.ClientSentData(clientID, type, result); }