Ejemplo n.º 1
0
        protected void OnUdpProtocolEvent(UdpProtocolEvent evt)
        {
            switch (evt.EventType)
            {
            case UdpProtocolEvent.Type.Connected:
                callbacks.OnConnected(0);
                break;

            case UdpProtocolEvent.Type.Synchronizing:
                var syncEvt = evt as SynchronizingEvent;
                callbacks.OnSynchronizing(0, syncEvt.Count, syncEvt.Total);
                break;

            case UdpProtocolEvent.Type.Synchronized:
                if (isSynchronizing)
                {
                    callbacks.OnSyncrhonized(0);
                    callbacks.OnRunning();
                    isSynchronizing = false;
                }
                break;

            case UdpProtocolEvent.Type.NetworkInterrupted:
                var netEvt = evt as NetworkInterruptedEvent;
                callbacks.OnConnectionInterrupted(0, netEvt.DisconnectTimeout);
                break;

            case UdpProtocolEvent.Type.NetworkResumed:
                callbacks.OnConnectionResumed(0);
                break;

            case UdpProtocolEvent.Type.Disconnected:
                callbacks.OnDisconnected(0);
                break;

            case UdpProtocolEvent.Type.Input:
                var inputEvt = evt as InputEvent;

                host.SetLocalFrameNumber(inputEvt.Input.frame);
                host.SendInputAck();
                inputs[inputEvt.Input.frame % SpectatorFrameBufferSize] = inputEvt.Input;
                break;
            }
        }