示例#1
0
 void ChangeStatus(NetworkServerStatus status)
 {
     Status = status;
     if (StatusChange != null)
     {
         StatusChange();
     }
 }
示例#2
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;
        }
示例#3
0
 // Use this for initialization
 void Start()
 {
     m_lastServerStatus = NetworkStatus.serverStatus;
     m_lastClientStatus = NetworkStatus.clientStatus;
 }