コード例 #1
0
        /// <summary>
        /// Client is requesting data.
        /// </summary>
        public static int OnRecv(long s, byte[] buff, int len, int flags)
        {
            CheckThread();

            lock (SyncRoot) {
                if (ultimaSocket != null && ultimaSocket.Socket == s)
                {
                    return(ultimaSocket.Recv(s, buff, len, flags));
                }
                else
                {
                    return(WinSock.recv(s, buff, len, flags));
                }
            }
        }
コード例 #2
0
ファイル: UltimaSocket.cs プロジェクト: byterj/phoenix
        /// <summary>
        /// Reads data from server.
        /// </summary>
        public void ReceiveData()
        {
            CommunicationManager.CheckThread();

            lock (CommunicationManager.SyncRoot)
            {
                const int BuffLen = 65536;

                byte[] encryptedBuffer = new byte[BuffLen];
                int    readBytes       = WinSock.recv(socket, encryptedBuffer, BuffLen, 0);

                if (readBytes > 0)
                {
                    CommunicationManager.BandwidthManager.Download(readBytes);

                    byte[] decryptedBuffer = serverEncryption.Decrypt(encryptedBuffer, readBytes);
                    ProcessMessages(decryptedBuffer, true);
                }
            }
        }