コード例 #1
0
ファイル: Packet.cs プロジェクト: andy012345/WoWServer
        public void ReadHandler(byte[] data, int dataIndex, int dataSize)
        {
            int copyAmount = 0;

            var res = OnReceive(data, dataIndex, dataSize, out copyAmount);

            if (res == PacketProcessResult.Error) //Unknown data on a stream that doesn't have a reported size
            {
                ClientConnection.Dispose();
                return;
            }

            if (res == PacketProcessResult.Processed)
            {
                CurrentPacket.Reset();
                DataNeeded = DefaultDataNeeded();

                var realmProcessor = this as RealmPacketProcessor;
                if (realmProcessor != null)
                {
                    realmProcessor.DecryptPointer = 0;
                }
            }
            dataIndex += copyAmount;

            if (dataIndex < dataSize)
            {
                //we have more data to process
                ReadHandler(data, dataIndex, dataSize);
            }
        }
コード例 #2
0
ファイル: Socket.cs プロジェクト: andy012345/WoWServer
        public Task OnNextAsync(SocketCommand item, StreamSequenceToken token)
        {
            switch (item.GetCommand())
            {
            case SocketCommands.DisconnectClient:
            {
                sock.Dispose();
            }
            break;

            case SocketCommands.SetAccount:
            {
                sock.CurrentAccount = (IAccount)item.GetData(0);
            }
            break;

            case SocketCommands.SetPlayer:
            {
                sock.CurrentPlayer = (IPlayer)item.GetData(0);
            }
            break;

            case SocketCommands.ClearAccount:
            {
                sock.CurrentAccount = null;
            }
            break;

            case SocketCommands.ClearPlayer:
            {
                sock.CurrentPlayer = null;
            }
            break;
            }

            return(TaskDone.Done);
        }