bool HandleData(byte[] data) { receivedPacket.SetBytes(data); int packetLength = 0; if (receivedPacket.UnreadLength() >= 4) { packetLength = receivedPacket.ReadInt(); if (packetLength <= 0) { return(true); } } while (packetLength > 0 && packetLength <= receivedPacket.UnreadLength()) { byte[] receivedData = receivedPacket.ReadBytes(packetLength); ThreadManager.ExecuteOnMainThread(() => { using (Packet packet = new Packet(receivedData)) { int packetId = packet.ReadInt(); Server.packetHandlers[packetId](id, packet); } }); if (receivedPacket.UnreadLength() >= 4) { packetLength = receivedPacket.ReadInt(); if (packetLength <= 0) { return(true); } } } if (packetLength <= 1) { return(true); } return(false); }
private bool handleData(byte[] data) { int pLenght = 0; recievedData.SetBytes(data); if (recievedData.UnreadLength() >= 4) { pLenght = recievedData.ReadInt(); if (pLenght <= 0) { return(true); } } while (pLenght > 0 && pLenght <= recievedData.UnreadLength()) { byte[] pBytes = recievedData.ReadBytes(pLenght); ThreadManager.ExecuteOnMainThread(() => { using (Packet P = new Packet(pBytes)) { int PID = P.ReadInt(); Server.Managers[PID](id, P); } }); pLenght = 0; if (recievedData.UnreadLength() >= 4) { pLenght = recievedData.ReadInt(); if (pLenght <= 0) { return(true); } } } if (pLenght <= 1) { return(true); } else { return(false); } }
private bool HandleData(byte[] _data) { int _packetLength = 0; receivedData.SetBytes(_data); if (receivedData.UnreadLength() >= 4) { _packetLength = receivedData.ReadInt(); if (_packetLength <= 0) { return(true); } } while (_packetLength > 0 && _packetLength <= receivedData.UnreadLength()) { byte[] _packetBytes = receivedData.ReadBytes(_packetLength); ThreadManager.ExecuteOnMainThread(() => { using (Packet _packet = new Packet(_packetBytes)) { int _packetId = _packet.ReadInt(); GameServer.packetHandlers[_packetId](id, _packet); } }); _packetLength = 0; if (receivedData.UnreadLength() >= 4) { _packetLength = receivedData.ReadInt(); if (_packetLength <= 0) { return(true); } } } return(_packetLength <= 1); }
private bool HandleData(byte[] data) { int packetLength = 0; recievedData.SetBytes(data); if (recievedData.UnreadLength() >= 4) { packetLength = recievedData.ReadInt(); if (packetLength <= 0) { return(true); } } while (packetLength > 0 && packetLength <= recievedData.UnreadLength()) { byte[] packetBytes = recievedData.ReadBytes(packetLength); ThreadManager.ExecuteOnMainThread(() => { using (Packet p = new Packet(packetBytes)) { int packetId = p.ReadInt(); Server.packetHandlers[packetId](id, p); } }); packetLength = 0; if (recievedData.UnreadLength() >= 4) { packetLength = recievedData.ReadInt(); if (packetLength <= 0) { return(true); } } } return(packetLength <= 1); }