Пример #1
0
        /// <summary>
        /// Instructs the client to perform an update handshake with the AC server.
        /// </summary>
        public void PerformUpdateHandshake()
        {
            Handshaker hs = new Handshaker
            {
                Identifier  = 1,
                Version     = 1,
                OperationId = 1 // Update connection operation;
            };

            byte[] packet = this.GetBytes(hs);
            this.udpClient.Send(packet, packet.Length, this.serverEndPoint);
        }
Пример #2
0
        private byte[] GetBytes(Handshaker hs)
        {
            int size = Marshal.SizeOf(hs);

            byte[] arr = new byte[size];

            IntPtr ptr = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(hs, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);
            return(arr);
        }
Пример #3
0
        /// <summary>
        /// Performs the initial handshake to open connection with the AC server.
        /// </summary>
        /// <returns>The response from the server</returns>
        public HandshakerResponse?PerformInitialHandshake()
        {
            Handshaker hs = new Handshaker
            {
                Identifier  = 1,
                Version     = 1,
                OperationId = 0 // Open connection operation;
            };

            byte[] packet = this.GetBytes(hs);
            this.udpClient.Send(packet, packet.Length, this.serverEndPoint);

            try
            {
                return(this.GetHandshakerResponse(this.udpClient.Receive(ref this.serverEndPoint)));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }