private void readLoginSuccesfullStuff(IncomingPacket encPacket) { this.Slots = encPacket.ReadInt32(); }
void OnNewPacket(IncomingPacket encPacket) { short length = encPacket.ReadInt16(); int version = encPacket.ReadInt32(); string encryptedPacket = encPacket.ReadString(); try { byte[] decryptedPacket = this.RSAService.DecryptString(encryptedPacket); IncomingPacket packet = new IncomingPacket(decryptedPacket); short messageLength = packet.ReadInt16(); int messageID = packet.ReadInt32(); string dateTime = packet.ReadString(); DateTime sendTime = DateTime.Parse(dateTime); DateTime now = DateTime.UtcNow; if (Math.Abs((sendTime - now).TotalHours) > 2) { GotoDemoMode(); return; } switch (messageID) { case 1: readLoginSuccesfullStuff(encPacket); break; case 2: GotoDemoMode(); break; } } catch (EndOfStreamException) { //TODO fix malformed packet exception and kill connections maybe? or goto demo mode } catch { this.ClientModule.disconnect(); } }
private void HandlePacket(IncomingPacket message) { if (this.packetArrival != null) this.packetArrival.Invoke(message); }