Пример #1
0
    public static void Connect()
    {
        MessageBox_N.ShowMaskBox(MsgInfoType.ServerLoginMask, PELocalization.GetString(8000062));
        ProxyServerRegistered proxyServer = MyServerManager.LocalHost as ProxyServerRegistered;

        if (null != proxyServer && !proxyServer.IsLan && proxyServer.UseProxy)
        {
            NetworkInterface.Connect(proxyServer.ProxyServer,
                                     MyServerManager.LocalPwd,
                                     GameClientLobby.role.steamId,
                                     GameClientLobby.role.roleID,
                                     GameClientLobby.role);
        }
        else
        {
            NetworkInterface.Connect(MyServerManager.LocalIp,
                                     MyServerManager.LocalPort,
                                     MyServerManager.LocalPwd,
                                     GameClientLobby.role.steamId,
                                     GameClientLobby.role.roleID,
                                     GameClientLobby.role);
        }

        OnDisconnectEvent += OnDisconnectFromServer;
    }
Пример #2
0
    //bool LockRoomList = false;
    IEnumerator UpdateRoomInfo()
    {
        mRoomListPage = 0;

        uLink.MasterServer.ipAddress  = ClientConfig.ProxyIP;
        uLink.MasterServer.port       = ClientConfig.ProxyPort;
        uLink.MasterServer.password   = "******";
        uLink.MasterServer.updateRate = 4f;

        uLink.MasterServer.RequestHostList("PatheaGame");
        uLink.MasterServer.DiscoverLocalHosts("PatheaGame", 9900, 9915);
        yield return(new WaitForSeconds(3f));

        while (true)
        {
            _serverListInter.Clear();
            _serverListLan.Clear();

            // Internet
            if (uLobby.Lobby.isConnected)
            {
                IEnumerable <uLobby.ServerInfo> lobbySrvs = uLobby.ServerRegistry.GetServers();
                foreach (uLobby.ServerInfo server in lobbySrvs)
                {
                    ServerRegistered reg = new ServerRegistered();
                    reg.AnalyseServer(server);
                    _serverListInter.Add(reg);
                }
            }

            uLink.HostData[] servers = uLink.MasterServer.PollHostList();
            foreach (uLink.HostData server in servers)
            {
                ProxyServerRegistered reg = new ProxyServerRegistered();
                reg.AnalyseServer(server, false);
                _serverListInter.Add(reg);
            }

            uLink.HostData[] datas = uLink.MasterServer.PollDiscoveredHosts();
            foreach (uLink.HostData data in datas)
            {
                ServerRegistered server = new ServerRegistered();
                server.AnalyseServer(data, true);
                _serverListLan.Add(server);
            }

            uLink.MasterServer.ClearHostList();
            uLink.MasterServer.ClearDiscoveredHosts();

            RefreshRoomList();

            uLink.MasterServer.RequestHostList("PatheaGame");
            uLink.MasterServer.DiscoverLocalHosts("PatheaGame", 9900, 9915);
            bGetRoomInfo = true;

            yield return(new WaitForSeconds(5f));
        }
    }