예제 #1
0
 /// <summary>
 ///     Handles the packet data.
 /// </summary>
 /// <param name="packet">The packet.</param>
 /// <param name="bytesReceived"></param>
 private void HandlePacketData(byte[] packet, int bytesReceived)
 {
     if (Parser != null)
     {
         Arc4ServerSide?.Parse(ref packet);
         Parser.HandlePacketData(packet, bytesReceived);
     }
 }
예제 #2
0
        /// <summary>
        ///     Sends the data.
        /// </summary>
        /// <param name="packet">The packet.</param>
        public void SendData(byte[] packet)
        {
            if (_socket != null && _socket.Connected)
            {
                Arc4ClientSide?.Parse(ref packet);

                try
                {
                    _socket.BeginSend(packet, 0, packet.Length, SocketFlags.None, OnSendCompleted, _socket);
                }
                catch (Exception e)
                {
                    HandleDisconnect(SocketError.ConnectionReset, e);
                }
            }
            else
            {
                Disconnect();
            }
        }