private void LoginSequence(GameClient client, IByteBuffer buffer) { var parser = new ByteParser(buffer.Copy()); if (parser.CommandId == commands.old_client.requests.VersionRequest.ID) { var cmd = new commands.old_client.requests.VersionRequest(); cmd.readCommand(buffer); var loginHandler = new ShipInitializationHandler(client, cmd.playerId, cmd.sessionId); loginHandler.Execute(); } else if (parser.CommandId == commands.new_client.requests.LoginRequest.ID) { var cmd = new commands.new_client.requests.LoginRequest(); cmd.readCommand(buffer); var loginHandler = new ShipInitializationHandler(client, cmd.playerId, cmd.sessionId, true); loginHandler.Execute(); } else { Console.WriteLine("Unrecognised Login sequence, something is wrong. Recording IP and command datas.."); Console.WriteLine("IP : " + client.IpEndPoint + "; Data command ID: " + parser.CommandId + ", Data command length: " + parser.Lenght); } }
public void LookUp(IByteBuffer buffer, GameClient client) { try { var parser = new ByteParser(buffer.Copy()); if (parser.CMD_ID == commands.old_client.requests.VersionRequest.ID) { var cmd = new commands.old_client.requests.VersionRequest(); cmd.readCommand(buffer); new ShipInitalizationHandler(client, cmd.playerId, cmd.sessionId); return; } if (parser.CMD_ID == commands.new_client.requests.LoginRequest.ID) { var cmd = new commands.new_client.requests.LoginRequest(); cmd.readCommand(buffer); new ShipInitalizationHandler(client, cmd.playerId, cmd.sessionId, true); return; } var gameSession = World.StorageManager.GetGameSession(client.UserId); if (gameSession != null) { if (gameSession.Player.UsingNewClient) { if (NewClientCommands.ContainsKey(parser.CMD_ID)) { NewClientCommands[parser.CMD_ID].execute(gameSession, buffer); } //else if (parser.CMD_ID != commands.new_client.LegacyModule.ID) Console.WriteLine("[3D] Received->{0} Instance: {1}", parser.CMD_ID, client.UserId); } else { if (OldClientCommands.ContainsKey(parser.CMD_ID)) { OldClientCommands[parser.CMD_ID].execute(gameSession, buffer); } //else if (parser.CMD_ID != commands.old_client.LegacyModule.ID) Console.WriteLine("[7.5.3] Received->{0} Instance: {1}", parser.CMD_ID, client.UserId); } if (parser.CMD_ID == commands.new_client.LegacyModule.ID || parser.CMD_ID == commands.old_client.LegacyModule.ID) { var packet = parser.readUTF(); if (packet.Contains('|')) { var splittedPacket = packet.Split('|'); if (LegacyCommands.ContainsKey(splittedPacket[0])) { LegacyCommands[splittedPacket[0]].execute(gameSession, splittedPacket); } //else Console.WriteLine("Received->{0} Instance: {1}", packet, client.UserId); } else { if (LegacyCommands.ContainsKey(packet)) { LegacyCommands[packet].execute(gameSession, new[] { packet }); } //else Console.WriteLine("Received->{0} Instance: {1}", packet, client.UserId); } } } } catch (Exception exception) { Console.WriteLine("Exception found.. Disconnecting user"); Console.WriteLine("Exception: " + exception + ";" + exception.StackTrace + ";" + exception.Message); if (client.UserId != 0) { // find session var session = World.StorageManager.GetGameSession(client.UserId); if (session != null) { session.Kick(); } else { client.Disconnect(); } } else { client.Disconnect(); } } }