コード例 #1
0
ファイル: Network.cs プロジェクト: ZoondEngine/ZEngine-Hack
        private async void ReceiveAsync(Client client)
        {
            if (client.AvailibleSocket != null)
            {
                int size = await ReceiveTask(client);

                if (size != 0)
                {
                    Buffer          _inBuffer = new Buffer(client.ReceivingData);
                    int             commandID = _inBuffer.Read <int>();
                    CommandResponse command   = m_Packets[commandID];
                    if (command != null)
                    {
                        command.Invoke(client);
                    }
                    else
                    {
                        throw new NetworkException($"Received incorrect command '{commandID}'. Response undefined.");
                    }

                    _inBuffer.Clear();
                    ReceiveAsync(client);
                }
                else
                {
                    AppendDisconnect(client);
                }
            }
        }