コード例 #1
0
        public bool ClientReceive(out TransportEventData eventData)
        {
            eventData = default(TransportEventData);
            if (clientPeer == null)
            {
                return(false);
            }

            clientPeer.Recv();

            if (clientPeer.eventQueue.Count == 0)
            {
                return(false);
            }

            if (!clientPeer.eventQueue.TryDequeue(out eventData))
            {
                return(false);
            }

            switch (eventData.type)
            {
            case ENetworkEvent.DisconnectEvent:
                // Disconnect from server
                StopClient();
                break;

            case ENetworkEvent.ErrorEvent:
                // Disconnect from server
                StopClient();
                break;
            }

            return(true);
        }
コード例 #2
0
        public bool ServerReceive(out TransportEventData eventData)
        {
            eventData = default(TransportEventData);
            if (serverPeer == null)
            {
                return(false);
            }

            serverPeer.Recv();

            if (serverPeer.eventQueue.Count == 0)
            {
                return(false);
            }

            return(serverPeer.eventQueue.TryDequeue(out eventData));
        }