Beispiel #1
0
        public void HandleRelayServerPacket(ref StackDataReader p)
        {
            long   ip   = p.ReadUInt32LE(); // use LittleEndian here
            ushort port = p.ReadUInt16BE();
            uint   seed = p.ReadUInt32BE();

            NetClient.LoginSocket.Disconnect();
            EncryptionHelper.Initialize(false, seed, (ENCRYPTION_TYPE)Settings.GlobalSettings.Encryption);

            NetClient.Socket.Connect(new IPAddress(ip), port)
            .ContinueWith
            (
                t =>
            {
                if (!t.IsFaulted)
                {
                    NetClient.Socket.EnableCompression();

                    unsafe
                    {
                        Span <byte> b = stackalloc byte[4] {
                            (byte)(seed >> 24), (byte)(seed >> 16), (byte)(seed >> 8), (byte)seed
                        };
                        StackDataWriter writer = new StackDataWriter(b);
                        NetClient.Socket.Send(writer.AllocatedBuffer, writer.BytesWritten, true, true);
                        writer.Dispose();
                    }

                    NetClient.Socket.Send_SecondLogin(Account, Password, seed);
                }
            },
                TaskContinuationOptions.ExecuteSynchronously
            );
        }