/// <summary>
        /// 启动连接
        /// </summary>
        /// <returns></returns>
        public static bool Start()
        {
            try
            {
                ClientDispatcher.SetLoger(new ServerLinkLoger());

                //拷贝配置文件
                DictClientLink.Clear();
                foreach (var conf in Conf.SysServerList.Values)
                {
                    //if (conf.ServerType == (int)EServerType.世界)//|| conf.ServerType == (int)EServerType.数据中心)
                    //{
                    //    var client = new ClientLink();
                    //    client.Setup(ConstsBase.Ip本机, conf.Id, conf.ServerType);
                    //    DictClientLink.Add(client.LinkId, client);
                    //}
                }

                AutoCheckLink();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 启动连接
        /// </summary>
        /// <returns></returns>
        public static bool Start()
        {
            try
            {
                ClientDispatcher.SetLoger(new ServerLinkLoger());

                DictServerLinkGame.Clear();
                DictServerLinkLogin.Clear();
                foreach (var conf in Conf.SysServerList.Values)
                {
                    if (conf.ServerType == (int)EServerType.游戏)
                    {
                        var client = new ClientLink();
                        client.Setup(ConstsBase.Ip本机, conf.Id, conf.ServerType, conf.Desc);
                        DictServerLinkGame.Add(client.LinkId, client);
                    }
                    else if (conf.ServerType == (int)EServerType.登陆)
                    {
                        var client = new ClientLink();
                        client.Setup(ConstsBase.Ip本机, conf.Id, conf.ServerType, conf.Desc);
                        DictServerLinkLogin.Add(client.LinkId, client);
                    }
                }

                AutoCheckLink();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            comboBox1.SelectedIndex = 0;

            ClientDispatcher.SetLoger(this);

            ClientDispatcher.BindEventHandler(OnLoginUserLogin, EProtocolId.L2E_GAME_LOGINSERVER);
            ClientDispatcher.BindEventHandler(OnLoginUserRegister, EProtocolId.L2E_GAME_REGISTER);
            ClientDispatcher.BindEventHandler(OnPlayerXY, EProtocolId.G2E_GAME_PLAYERXY);
            ClientDispatcher.BindEventHandler(OnPlayerXYOther, EProtocolId.G2E_GAME_PLAYERXYOTHER);
            ClientDispatcher.BindEventHandler(OnPlayerLoginOut, EProtocolId.G2E_GAME_LOGINOUT);
            ClientDispatcher.BindEventHandler(OnPlayerMapInOther, EProtocolId.G2E_GAME_MAPINOTHER);
            ClientDispatcher.BindEventHandler(OnPlayerMapIn, EProtocolId.G2E_GAME_MAPIN);
            tabControl1.SelectedIndex = 0;
        }