Example #1
0
        public ULocalConnectionToClient(LocalClient localClient) : base("localClient")
        {
            this.localClient = localClient;

            // local player always has connectionId == 0
            connectionId = 0;
        }
Example #2
0
 public static NetworkClient ConnectLocalServer()
 {
     LocalClient newClient = new LocalClient();
     NetworkServer.ActivateLocalClientScene();
     newClient.InternalConnectLocalServer(true);
     return newClient;
 }
Example #3
0
        // called by LocalClient to add itself. dont call directly.
        internal static int AddLocalClient(LocalClient localClient)
        {
            if (s_LocalConnection != null)
            {
                Debug.LogError("Local Connection already exists");
                return(-1);
            }

            s_LocalConnection = new ULocalConnectionToClient(localClient);
            s_LocalConnection.connectionId = 0;
            AddConnection(s_LocalConnection);

            s_LocalConnection.InvokeHandlerNoData((short)MsgType.Connect);
            return(0);
        }
Example #4
0
        // called by LocalClient to add itself. dont call directly.
        internal static int AddLocalClient(LocalClient localClient)
        {
            if (s_LocalConnection != null)
            {
                Debug.LogError("Local Connection already exists");
                return(-1);
            }

            s_LocalConnection = new ULocalConnectionToClient(localClient)
            {
                connectionId = 0
            };
            OnConnected(s_LocalConnection);
            return(0);
        }
Example #5
0
        /// <summary>
        /// This shuts down the server and disconnects all clients.
        /// </summary>
        public void Disconnect()
        {
            if (LocalClient != null)
            {
                OnStopHost.Invoke();
                LocalClient.Disconnect();
            }

            foreach (INetworkConnection conn in connections)
            {
                conn.Disconnect();
            }
            if (transport != null)
            {
                transport.Disconnect();
            }
        }
Example #6
0
        /// <summary>
        /// This shuts down the server and disconnects all clients.
        /// </summary>
        public void Disconnect()
        {
            if (LocalClient != null)
            {
                OnStopHost.Invoke();
                LocalClient.Disconnect();
            }

            // make a copy,  during disconnect, it is possible that connections
            // are modified, so it throws
            // System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
            var connectionscopy = new HashSet <INetworkConnection>(connections);

            foreach (INetworkConnection conn in connectionscopy)
            {
                conn.Disconnect();
            }
            if (Transport != null)
            {
                Transport.Disconnect();
            }
        }
Example #7
0
 public ULocalConnectionToClient(LocalClient localClient) : base("localClient")
 {
     this.localClient = localClient;
 }
Example #8
0
 public ULocalConnectionToClient(LocalClient localClient)
 {
     address       = "localClient";
     m_LocalClient = localClient;
 }