public bool CreateConnector(ConnectorParam param)
 {
     this.DestroyConnector();
     if (param == null)
     {
         return(false);
     }
     this.initParam = param;
     this.connected = false;
     this.connector = IApollo.Instance.CreateApolloConnection(ApolloConfig.platform, (uint)0xffffff, param.url);
     if (this.connector == null)
     {
         return(false);
     }
     Console.WriteLine("Create Connect Entered!{0}  {1}", ApolloConfig.platform, param.url);
     this.connector.ConnectEvent    += new ConnectEventHandler(this.onConnectEvent);
     this.connector.DisconnectEvent += new DisconnectEventHandler(this.onDisconnectEvent);
     this.connector.ReconnectEvent  += new ReconnectEventHandler(this.onReconnectEvent);
     this.connector.ErrorEvent      += new ConnectorErrorEventHandler(this.onConnectError);
     this.connector.SetSecurityInfo(param.enc, param.keyMaking, ConnectorParam.DH);
     if (this.connector.Connect(connectTimeout) != ApolloResult.Success)
     {
         return(false);
     }
     return(true);
 }
        public bool ConnectServer()
        {
            this.canReconnect = true;
            if (Singleton <NetworkModule> .GetInstance().isOnlineMode&& !this.isLogin)
            {
                Singleton <NetworkModule> .GetInstance().lobbySvr.ConnectedEvent -= new NetConnectedEvent(this.onLobbyConnected);

                Singleton <NetworkModule> .GetInstance().lobbySvr.DisconnectEvent -= new NetDisconnectEvent(this.onLobbyDisconnected);

                Singleton <NetworkModule> .GetInstance().lobbySvr.ConnectedEvent += new NetConnectedEvent(this.onLobbyConnected);

                Singleton <NetworkModule> .GetInstance().lobbySvr.DisconnectEvent += new NetDisconnectEvent(this.onLobbyDisconnected);

                LobbyConnector expr_97 = Singleton <NetworkModule> .GetInstance().lobbySvr;

                expr_97.GetTryReconnect = (LobbyConnector.DelegateGetTryReconnect)Delegate.Remove(expr_97.GetTryReconnect, new LobbyConnector.DelegateGetTryReconnect(this.OnTryReconnect));
                LobbyConnector expr_C2 = Singleton <NetworkModule> .GetInstance().lobbySvr;

                expr_C2.GetTryReconnect = (LobbyConnector.DelegateGetTryReconnect)Delegate.Combine(expr_C2.GetTryReconnect, new LobbyConnector.DelegateGetTryReconnect(this.OnTryReconnect));
                ConnectorParam connectorParam = new ConnectorParam();
                connectorParam.url   = ApolloConfig.loginUrl;
                connectorParam.ip    = ApolloConfig.loginOnlyIpOrUrl;
                connectorParam.vPort = ApolloConfig.loginOnlyVPort;
                bool flag = Singleton <NetworkModule> .GetInstance().InitLobbyServerConnect(connectorParam);

                if (flag)
                {
                    Singleton <CUIManager> .GetInstance().OpenSendMsgAlert(null, 10, enUIEventID.None);
                }
                return(flag);
            }
            return(false);
        }
Exemple #3
0
        public static void InitRelayConnnecting(COMDT_TGWINFO inRelayTgw)
        {
            if (inRelayTgw.dwVipCnt > 0)
            {
                string host = null;
                if (MonoSingleton <CTongCaiSys> .GetInstance().IsCanUseTongCai())
                {
                    host = ApolloConfig.loginOnlyIpOrUrl;
                }
                else if ((inRelayTgw.szRelayUrl.Length > 0) && (inRelayTgw.szRelayUrl[0] != 0))
                {
                    host = StringHelper.UTF8BytesToString(ref inRelayTgw.szRelayUrl);
                }
                else
                {
                    host = ApolloConfig.loginOnlyIpOrUrl;
                }
                Singleton <ReconnectIpSelect> .instance.SetRelayTgw(inRelayTgw);

                LookUpDNSOfServerAndConfigNetAcc(host, inRelayTgw.wEchoPort);
                ConnectorParam para = new ConnectorParam {
                    bIsUDP = (inRelayTgw.bIsUDP <= 0) ? false : true,
                    ip     = host
                };
                para.SetVPort(inRelayTgw.wVPort);
                NetworkAccelerator.ClearUDPCache();
                NetworkAccelerator.SetEchoPort(inRelayTgw.wEchoPort);
                ApolloConfig.echoPort = inRelayTgw.wEchoPort;
                Singleton <NetworkModule> .GetInstance().InitGameServerConnect(para);
            }
        }
Exemple #4
0
        public bool ConnectServer()
        {
            if (!Singleton <NetworkModule> .GetInstance().isOnlineMode || this.isLogin)
            {
                return(false);
            }
            Singleton <NetworkModule> .GetInstance().lobbySvr.ConnectedEvent -= new NetConnectedEvent(this.onLobbyConnected);

            Singleton <NetworkModule> .GetInstance().lobbySvr.DisconnectEvent -= new NetDisconnectEvent(this.onLobbyDisconnected);

            Singleton <NetworkModule> .GetInstance().lobbySvr.ConnectedEvent += new NetConnectedEvent(this.onLobbyConnected);

            Singleton <NetworkModule> .GetInstance().lobbySvr.DisconnectEvent += new NetDisconnectEvent(this.onLobbyDisconnected);

            Singleton <NetworkModule> .GetInstance().lobbySvr.GetTryReconnect = (LobbyConnector.DelegateGetTryReconnect)Delegate.Remove(Singleton <NetworkModule> .GetInstance().lobbySvr.GetTryReconnect, new LobbyConnector.DelegateGetTryReconnect(this.OnTryReconnect));

            Singleton <NetworkModule> .GetInstance().lobbySvr.GetTryReconnect = (LobbyConnector.DelegateGetTryReconnect)Delegate.Combine(Singleton <NetworkModule> .GetInstance().lobbySvr.GetTryReconnect, new LobbyConnector.DelegateGetTryReconnect(this.OnTryReconnect));

            ConnectorParam para = new ConnectorParam {
                url   = ApolloConfig.loginUrl,
                ip    = ApolloConfig.loginOnlyIpOrUrl,
                vPort = ApolloConfig.loginOnlyVPort
            };
            bool flag = Singleton <NetworkModule> .GetInstance().InitLobbyServerConnect(para);

            if (flag)
            {
                Singleton <CUIManager> .GetInstance().OpenSendMsgAlert(null, 10, enUIEventID.None);
            }
            return(flag);
        }
        public static void InitRelayConnnecting(COMDT_TGWINFO inRelayTgw)
        {
            if (inRelayTgw.dwVipCnt > 0u)
            {
                string text;
                if (MonoSingleton <CTongCaiSys> .GetInstance().IsCanUseTongCai())
                {
                    text = ApolloConfig.loginOnlyIpOrUrl;
                }
                else if (inRelayTgw.szRelayUrl.Length > 0 && inRelayTgw.szRelayUrl[0] != 0)
                {
                    text = StringHelper.UTF8BytesToString(ref inRelayTgw.szRelayUrl);
                }
                else
                {
                    text = ApolloConfig.loginOnlyIpOrUrl;
                }
                MonoSingleton <GSDKsys> .GetInstance().DetermineWhichSpeed();

                Singleton <ReconnectIpSelect> .instance.SetRelayTgw(inRelayTgw);

                NetworkModule.LookUpDNSOfServerAndConfigNetAcc(text, (int)inRelayTgw.wEchoPort);
                ConnectorParam connectorParam = new ConnectorParam();
                connectorParam.bIsUDP = (inRelayTgw.bIsUDP > 0);
                connectorParam.ip     = text;
                connectorParam.SetVPort(inRelayTgw.wVPort);
                NetworkAccelerator.ClearUDPCache();
                NetworkAccelerator.SetEchoPort((int)inRelayTgw.wEchoPort);
                NetworkAccelerator.SetConnectIP(text, inRelayTgw.wVPort);
                ApolloConfig.echoPort = inRelayTgw.wEchoPort;
                Singleton <NetworkModule> .GetInstance().InitGameServerConnect(connectorParam);

                MonoSingleton <GSDKsys> .GetInstance().StartSpeed(text, (int)inRelayTgw.wVPort);
            }
        }
Exemple #6
0
 public bool Init(ConnectorParam para)
 {
     this.reconPolicy.SetConnector(this, new tryReconnectDelegate(this.onTryReconnect), 4);
     ApolloNetworkService.Intance.NetworkChangedEvent -= new Apollo.NetworkStateChanged(this.NetworkStateChanged);
     ApolloNetworkService.Intance.NetworkChangedEvent += new Apollo.NetworkStateChanged(this.NetworkStateChanged);
     return(base.CreateConnector(para));
 }
 public bool Init(ConnectorParam para)
 {
     this.reconPolicy.SetConnector(this, new tryReconnectDelegate(this.onTryReconnect), 8u);
     ApolloNetworkService.Intance.remove_NetworkChangedEvent(new NetworkStateChanged(this.NetworkStateChanged));
     ApolloNetworkService.Intance.add_NetworkChangedEvent(new NetworkStateChanged(this.NetworkStateChanged));
     this.curNetworkReachability = Application.internetReachability;
     return(base.CreateConnector(para));
 }
        public bool InitGameServerConnect(ConnectorParam para)
        {
            MonoSingleton <Reconnection> .GetInstance().ResetRelaySyncCache();

            Singleton <FrameWindow> .GetInstance().Reset();

            return(this.gameSvr.Init(para));
        }
Exemple #9
0
 public bool CreateConnector(ConnectorParam param)
 {
     this.DestroyConnector();
     if (param == null)
     {
         return(false);
     }
     this.initParam = param;
     this.connected = false;
     this.connector = IApollo.get_Instance().CreateApolloConnection(ApolloConfig.platform, 16777215u, param.url);
     if (this.connector == null)
     {
         return(false);
     }
     Console.WriteLine("Create Connect Entered!{0}  {1}", ApolloConfig.platform, param.url);
     this.connector.add_ConnectEvent(new ConnectEventHandler(this.onConnectEvent));
     this.connector.add_DisconnectEvent(new DisconnectEventHandler(this.onDisconnectEvent));
     this.connector.add_ReconnectEvent(new ReconnectEventHandler(this.onReconnectEvent));
     this.connector.add_ErrorEvent(new ConnectorErrorEventHandler(this.onConnectError));
     this.connector.SetSecurityInfo(param.enc, param.keyMaking, ConnectorParam.DH);
     return(this.connector.Connect(BaseConnector.connectTimeout) == null);
 }
Exemple #10
0
 public bool Init(ConnectorParam para)
 {
     this.reconPolicy.SetConnector(this, new tryReconnectDelegate(this.onTryReconnect), 8);
     return(base.CreateConnector(para));
 }
 public bool InitLobbyServerConnect(ConnectorParam para)
 {
     this.m_lobbyReconnetCount = 0;
     this.isOnlineMode         = true;
     return(this.lobbySvr.Init(para));
 }