public void HandlePacket(SOEClient sender, SOEPacket packet) { // Operation ushort opCode = packet.GetOpCode(); // Security Measure if (!sender.HasSession()) { if (opCode != (ushort)SOEOPCodes.SESSION_REQUEST) { // We really don't care about this client. // They can try send stuff as much as possible. // TODO: Handle this (cuz attacks) return; } } // Handle! switch ((SOEOPCodes)opCode) { case SOEOPCodes.SESSION_REQUEST: HandleSessionRequest(sender, packet); break; case SOEOPCodes.MULTI: Console.WriteLine("MULTI!"); // TODO break; case SOEOPCodes.DISCONNECT: HandleDisconnect(sender, packet); break; case SOEOPCodes.PING: HandlePing(sender); break; case SOEOPCodes.RELIABLE_DATA: case SOEOPCodes.FRAGMENTED_RELIABLE_DATA: case SOEOPCodes.ACK_RELIABLE_DATA: sender.DataChannel.Receive(packet); break; default: Log("Received Unknown SOEPacket 0x{0:X2}!", packet.GetOpCode()); break; } }
public void Receive(SOEPacket packet) { ushort opCode = packet.GetOpCode(); if (opCode == (ushort)SOEOPCodes.FRAGMENTED_RELIABLE_DATA) { ReceiveFragment(packet); } else if (opCode == (ushort)SOEOPCodes.RELIABLE_DATA) { ReceiveMessage(packet); } else if (opCode == (ushort)SOEOPCodes.ACK_RELIABLE_DATA) { // TODO: Handle repeat-until-acknowledged and all that comes with it. Log("Data Ack"); } else { // Shrug ¯\_(ツ)_/¯ Log("Received a packet that was not data or acknowledge. Discarding.."); } }