Beispiel #1
0
        private void OnClientReceivedData(Client2 client)
        {
            UnityClient unityClient = Resolve(client);

            trace(client.endpointIn + ": <<<<< RECEIVED: " + _receivedBytesLength);

            //If was 'SLEEPING' (partially timed-out), set it's status to WAKING:
            if (unityClient.HasStatus(EClientStatus.SLEEPING))
            {
                unityClient.status &= ~EClientStatus.SLEEPING;
                unityClient.status |= EClientStatus.WAKING;

                if (OnStatusWaking != null)
                {
                    OnStatusWaking(unityClient);
                }
            }
            else if (unityClient.HasStatus(EClientStatus.WAKING))
            {
                unityClient.status &= ~EClientStatus.WAKING;

                if (OnStatusReturned != null)
                {
                    OnStatusReturned(unityClient);
                }
            }

            //Alright, set the client's status and time-received stamp:
            double timeNow = GetTimeSinceStart();

            unityClient.timeDiff         = timeNow - unityClient.timeLastReceived;
            unityClient.timeLastReceived = timeNow;
            unityClient.status          |= EClientStatus.CONNECTED;
        }
Beispiel #2
0
        private void OnNewUnityClient(Client2 client)
        {
            if (clientsUnity.ContainsKey(client))
            {
                throw new Exception("OnNewUnityClient ERROR - Already has the client, NOT NEW: " + client.ToString());
            }

            //Pass '-1' to the clockRate to indicate we will manually control the Message flow with a few server binding hooks:
            UnityClient unityClient = new UnityClient(client, -1);

            unityClient.server   = this;
            clientsUnity[client] = unityClient;
        }