コード例 #1
0
    private void OnReceivePacket()
    {
        while (Connected)
        {
            int readBytesCount = 0;
            try
            {
                readBytesCount = _Stream.Read(_ReciveBytes, 0, _ReciveBytes.Length);
            }
            catch
            {
                NetworkServer.Get().Disconnect(this);
            }

            if (readBytesCount > 0)
            {
                INetworkPacket networkPacket = _ReciveBytes.ToNetworkPacket();
                NetworkServer.Get().OnReceivePacket(this, networkPacket);
            }
            else
            {
                break;
            }
        }
        NetworkServer.Get().Disconnect(this);
    }