Connect() приватный Метод

private Connect ( int hostId, string address, int port, int exeptionConnectionId, byte &error ) : int
hostId int
address string
port int
exeptionConnectionId int
error byte
Результат int
Пример #1
0
        internal void ContinueConnect()
        {
            byte num;

            if (this.m_UseSimulator)
            {
                int outMinDelay = this.m_SimulatedLatency / 3;
                if (outMinDelay < 1)
                {
                    outMinDelay = 1;
                }
                if (LogFilter.logDebug)
                {
                    Debug.Log(string.Concat(new object[] { "Connect Using Simulator ", this.m_SimulatedLatency / 3, "/", this.m_SimulatedLatency }));
                }
                ConnectionSimulatorConfig conf = new ConnectionSimulatorConfig(outMinDelay, this.m_SimulatedLatency, outMinDelay, this.m_SimulatedLatency, this.m_PacketLoss);
                this.m_ClientConnectionId = NetworkTransport.ConnectWithSimulator(this.m_ClientId, this.m_ServerIp, this.m_ServerPort, 0, out num, conf);
            }
            else
            {
                this.m_ClientConnectionId = NetworkTransport.Connect(this.m_ClientId, this.m_ServerIp, this.m_ServerPort, 0, out num);
            }
            this.m_Connection = (NetworkConnection)Activator.CreateInstance(this.m_NetworkConnectionClass);
            this.m_Connection.SetHandlers(this.m_MessageHandlers);
            this.m_Connection.Initialize(this.m_ServerIp, this.m_ClientId, this.m_ClientConnectionId, this.m_HostTopology);
        }
Пример #2
0
        internal void ContinueConnect()
        {
            byte error;

            // regular non-relay connect
            if (m_UseSimulator)
            {
                int simLatency = m_SimulatedLatency / 3;
                if (simLatency < 1)
                {
                    simLatency = 1;
                }

                if (LogFilter.logDebug)
                {
                    Debug.Log("Connect Using Simulator " + (m_SimulatedLatency / 3) + "/" + m_SimulatedLatency);
                }
                var simConfig = new ConnectionSimulatorConfig(
                    simLatency,
                    m_SimulatedLatency,
                    simLatency,
                    m_SimulatedLatency,
                    m_PacketLoss);

                m_ClientConnectionId = NetworkTransport.ConnectWithSimulator(m_ClientId, m_ServerIp, m_ServerPort, 0, out error, simConfig);
            }
            else
            {
                m_ClientConnectionId = NetworkTransport.Connect(m_ClientId, m_ServerIp, m_ServerPort, 0, out error);
            }

            m_Connection = (NetworkConnection)Activator.CreateInstance(m_NetworkConnectionClass);
            m_Connection.SetHandlers(m_MessageHandlers);
            m_Connection.Initialize(m_ServerIp, m_ClientId, m_ClientConnectionId, m_HostTopology);
        }
Пример #3
0
        internal void ContinueConnect()
        {
            byte error;

            if (m_UseSimulator)
            {
                int num = m_SimulatedLatency / 3;
                if (num < 1)
                {
                    num = 1;
                }
                if (LogFilter.logDebug)
                {
                    Debug.Log("Connect Using Simulator " + m_SimulatedLatency / 3 + "/" + m_SimulatedLatency);
                }
                ConnectionSimulatorConfig conf = new ConnectionSimulatorConfig(num, m_SimulatedLatency, num, m_SimulatedLatency, m_PacketLoss);
                m_ClientConnectionId = NetworkTransport.ConnectWithSimulator(m_ClientId, m_ServerIp, m_ServerPort, 0, out error, conf);
            }
            else
            {
                m_ClientConnectionId = NetworkTransport.Connect(m_ClientId, m_ServerIp, m_ServerPort, 0, out error);
            }
            m_Connection = (NetworkConnection)Activator.CreateInstance(m_NetworkConnectionClass);
            m_Connection.SetHandlers(m_MessageHandlers);
            m_Connection.Initialize(m_ServerIp, m_ClientId, m_ClientConnectionId, m_HostTopology);
        }
Пример #4
0
 public static int ConnectEndPoint(int hostId, EndPoint endPoint, string relayAddress, int relayPort, int exceptionConnectionId, out byte error)
 {
     isClient = true;
     RelayTransport.address = ((IPEndPoint)endPoint).Address.ToString();
     RelayTransport.port    = (ushort)((IPEndPoint)endPoint).Port;
     relayConnectionId      = NetworkTransport.Connect(hostId, relayAddress, relayPort, exceptionConnectionId, out error); // Requests connection
     return(relayConnectionId);
 }
Пример #5
0
 public static int Connect(int hostId, string serverAddress, int serverPort, string relayAddress, int relayPort, int exceptionConnectionId, out byte error)
 {
     isClient = true;
     RelayTransport.address = serverAddress;
     RelayTransport.port    = (ushort)serverPort;
     relayConnectionId      = NetworkTransport.Connect(hostId, relayAddress, relayPort, exceptionConnectionId, out error); // Requests connection
     return(relayConnectionId);
     // Wait here until connect event is accepted
 }
Пример #6
0
        internal void ContinueConnect()
        {
            byte error;

            // regular non-relay connect
            m_ClientConnectionId = NetworkTransport.Connect(m_ClientId, m_ServerIp, m_ServerPort, 0, out error);
            m_Connection         = (NetworkConnection)Activator.CreateInstance(m_NetworkConnectionClass);
            m_Connection.SetHandlers(m_MessageHandlers);
            m_Connection.Initialize(m_ServerIp, m_ClientId, m_ClientConnectionId, m_HostTopology);
        }
Пример #7
0
        public static int AddWebsocketHost(HostTopology topology, int port, string ip, bool createServer, string relayAddress, int relayPort)
        {
            isClient = !createServer;
            SetChannelsFromTopology(topology);
            int ret = NetworkTransport.AddWebsocketHost(topology, port, ip);

            if (createServer)
            {
                relayConnectionId = NetworkTransport.Connect(ret, relayAddress, relayPort, 0, out byte b);
            }
            return(ret);
        }
Пример #8
0
        public static int AddHostWithSimulator(HostTopology topology, int minTimeout, int maxTimeout, int port, bool createServer, string relayAddress, int relayPort)
        {
            isClient = !createServer;
            SetChannelsFromTopology(topology);
            int ret = NetworkTransport.AddHostWithSimulator(topology, minTimeout, maxTimeout, port);

            if (createServer)
            {
                relayConnectionId = NetworkTransport.Connect(ret, relayAddress, relayPort, 0, out byte b);
            }
            return(ret);
        }
Пример #9
0
        public static int AddHost(HostTopology topology, bool createServer, string relayAddress, int relayPort)
        {
            isClient = !createServer;
            SetChannelsFromTopology(topology);
            int ret = NetworkTransport.AddHost(topology);

            if (createServer)
            {
                relayConnectionId = NetworkTransport.Connect(ret, relayAddress, relayPort, 0, out byte b);
                Debug.Log((NetworkError)b);
            }
            return(ret);
        }
Пример #10
0
        public override void StartClient()
        {
            if (NetworkManager.Get().enableLogging)
            {
                Debug.Log("Transport Start Client");
            }
            //SocketTask task = SocketTask.Working;

            serverHostID       = Unet.AddHost(new HostTopology(GetConfig(), 1));
            serverConnectionID = Unet.Connect(serverHostID, address, port, 0, out byte error);

            NetworkError connectError = (NetworkError)error;

            if (connectError != NetworkError.Ok)
            {
                //Throw Start Client failed exception
                throw new NetworkException("Unet failed to start client with error '" + connectError + "'.");
            }
        }
Пример #11
0
 public int Connect(int hostId, string address, int port, int specialConnectionId, out byte error)
 {
     return(NetworkTransport.Connect(hostId, address, port, specialConnectionId, out error));
 }