public Packet(int[] data, Client from) { this.data = data; packetID = ((data[0] & 0xff) << 8) | (data[1] & 0xff); length = ((data[2] & 0xff) << 16) | ((data[3] & 0xff) << 8) | (data[4] & 0xff); encryptedData = new int[length]; for (int i = 7; i <= length; i++) { encryptedData[i - 7] = this.data[i]; } Console.WriteLine("Packet received : " + packetID); this.from = from; }
public void HandleClient(object obj) { TcpClient client = (TcpClient) obj; Client clientInstance = new Client(client); Boolean bClientConnected = true; while (bClientConnected) { int[] data = readData(client.GetStream()); if (data != null) { clientInstance.packetHandler.handle(data); } } }
public PacketHandler(Client c) { this.c = c; }