Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            var newServerStatus = NetworkStatus.serverStatus;
            var newClientStatus = NetworkStatus.clientStatus;


            if (m_lastServerStatus != newServerStatus)
            {
                // server status changed

                if (newServerStatus == NetworkServerStatus.Started)
                {
                    InvokeEvent(onServerStarted);

                    this.Dispatch("OnServerStarted");
                }
                else if (newServerStatus == NetworkServerStatus.Starting)
                {
                    this.Dispatch("OnServerStarting");
                }
                else if (newServerStatus == NetworkServerStatus.Stopped)
                {
                    InvokeEvent(onServerStopped);

                    this.Dispatch("OnServerStopped");
                }
            }

            if (m_lastClientStatus != newClientStatus)
            {
                // client status changed

                if (newClientStatus == NetworkClientStatus.Connecting)
                {
                    InvokeEvent(onClientStartedConnecting);

                    this.Dispatch("OnClientStartedConnecting");
                }
                else if (newClientStatus == NetworkClientStatus.Connected)
                {
                    InvokeEvent(onClientConnected);

                    this.Dispatch("OnClientConnected");
                }
                else if (newClientStatus == NetworkClientStatus.Disconnected)
                {
                    InvokeEvent(onClientDisconnected);

                    this.Dispatch("OnClientDisconnected");
                }
            }


            m_lastServerStatus = newServerStatus;
            m_lastClientStatus = newClientStatus;
        }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     m_lastServerStatus = NetworkStatus.serverStatus;
     m_lastClientStatus = NetworkStatus.clientStatus;
 }