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); }
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)); }