Ejemplo n.º 1
0
        // -------------------------------------------

        /*
         * A client has been disconnected
         */
        public void ClientDisconnected(int _idConnection)
        {
            if (RemoveConnection(_idConnection))
            {
                string eventDisconnected = CommunicationsController.CreateJSONMessage(_idConnection, CommunicationsController.MESSAGE_TYPE_DISCONNECTION);
                Debug.Log(eventDisconnected);
                UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMAINCOMMANDCENTER_LIST_USERS, m_playersConnections);
                UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMAINCOMMANDCENTER_REGISTER_LOG, eventDisconnected);
                NetworkEventController.Instance.DispatchLocalEvent(NetworkEventController.EVENT_PLAYERCONNECTIONDATA_USER_DISCONNECTED, _idConnection);
            }
        }
        // -------------------------------------------

        /*
         * New client has been connected
         */
        public bool ClientNewConnection(int _idConnection)
        {
            PlayerConnectionData newPlayerConnection = new PlayerConnectionData(_idConnection, null);

            if (!m_playersConnections.Contains(newPlayerConnection))
            {
                m_playersConnections.Add(newPlayerConnection);
                string eventConnected = CommunicationsController.CreateJSONMessage(_idConnection, CommunicationsController.MESSAGE_TYPE_NEW_CONNECTION);
                Debug.Log(eventConnected);
                UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMAINCOMMANDCENTER_LIST_USERS, m_playersConnections);
                UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMAINCOMMANDCENTER_REGISTER_LOG, eventConnected);
                return(true);
            }
            else
            {
                return(false);
            }
        }