public void ExecuteIncomingPacket(Player player, IncomingPacket packet) { if (packet.PacketId == IncomingHeaders.SSOTicketMessageEvent) { if (_authenticationPassed) return; _authenticationPassed = true; } Apple.PacketManager.ExecuteIncomingPacket(player, packet); }
public void ExecuteIncomingPacket(Player player, IncomingPacket packet) { IPacketEvent Pak = null; if (!_packets.TryGetValue(packet.PacketId, out Pak)) { _log.Warn("Unhandled packet " + packet.PacketId); return; } Pak.handleIncomingPacket(player, packet); _log.Info("Handled packet " + packet.PacketId); }
private void OnReceiveData(IAsyncResult AsyncResult) { try { int bytesRead = _playerData.PlayerSocket.EndReceive(AsyncResult); if (bytesRead == 0) { Apple.Game.PlayerManager.DisposePlayer(_playerData.PlayerId); return; } byte[] packetData = new byte[bytesRead]; Array.Copy(_playerData.SocketBuffer, packetData, bytesRead); if (packetData.Length == 0) return; if (packetData[0] == 60) { SendData("<?xml version=\"1.0\"?>\r\n<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n<cross-domain-policy>\r\n<allow-access-from domain=\"*\" to-ports=\"" + Apple.Config.GetConfigElement("game.socket.port") + "\" />\r\n</cross-domain-policy>\0"); Apple.Game.PlayerManager.DisposePlayer(_playerData.PlayerId); } else if (packetData[0] != 67) { int packetPosition = 0; for (packetPosition = 0; packetPosition < packetData.Length; ) { int packetLength = Apple.Encoding.DecodeInt32(new [] { packetData[packetPosition++], packetData[packetPosition++], packetData[packetPosition++], packetData[packetPosition++] }); if (packetLength < 2 || packetLength > 4096) return; short packetId = Apple.Encoding.DecodeInt16(new[] { packetData[packetPosition++], packetData[packetPosition++] }); byte[] packetContent = new byte[packetLength - 2]; for (int i = 0; i < packetContent.Length && packetPosition < packetData.Length; i++) packetContent[i] = packetData[packetPosition++]; IncomingPacket incomingPacket = new IncomingPacket(packetId, packetContent); if (incomingPacket != null) _playerData.PacketManager.ExecuteIncomingPacket(this, incomingPacket); } } } catch (Exception e) { _log.Error(e); } finally { StartPacketProcessing(); } }