Example #1
0
        private async void StartRecv()
        {
            while (true)
            {
                if (this.Id == 0)
                {
                    return;
                }

                byte[] rMessageBytes;
                try
                {
                    if (mChannel == null)
                    {
                        return;
                    }

                    rMessageBytes = await mChannel.Recv();

                    if (this.Id == 0)
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                    continue;
                }

                if (rMessageBytes.Length < 3)
                {
                    continue;
                }

                ushort nOpcode = BitConverter.ToUInt16(rMessageBytes, 0);
                try
                {
                    this.Run(nOpcode, rMessageBytes);
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                }
            }
        }