Ejemplo n.º 1
0
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~登录~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        /// <summary>
        /// 登陆测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoginPageClick(object sender, EventArgs e)
        {
            if (m_tabLogin_Start.Text == "停止")
            {
                m_tabLogin_Start.Enabled = false;
                ClientNetManager.Instance.CloseAll();
                m_tabLogin_Start.Text    = "开始";
                m_tabLogin_Start.Enabled = true;
                EnableTabPage(true, m_tabLogin);
                EnableLoginTabPage(true);

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Login, false);
            }
            else
            {
                sPressureLoginInfo info = new sPressureLoginInfo();
                info.ip            = this.m_tabLogin_IP.Text;
                info.port          = ushort.Parse(this.m_tabLogin_Port.Text);
                info.client_count  = ushort.Parse(this.m_tabLogin_ClientCount.Text);
                info.dis_conn_time = float.Parse(this.m_tabLogin_DisconTime.Text);
                ServerConfig.net_info.login_server_ip    = info.ip;
                ServerConfig.net_info.login_server_port  = info.port;
                ServerConfig.net_info.login_client_count = info.client_count;

                m_tabLogin_Start.Enabled = false;
                EnableTabPage(false, m_tabLogin);
                EnableLoginTabPage(false);
                m_pressure_type       = ePressureType.Login;
                m_tabLogin_Start.Text = "停止";

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Login, true, info);
                ClientNetManager.Instance.StartConnect(info.ip, info.port, info.client_count, 8);
                m_tabLogin_Start.Enabled = true;
            }
        }
Ejemplo n.º 2
0
        private void OnGameEvent(GameEvent evt)
        {
            switch (evt.type)
            {
            case ClientEventID.NET_CONNECTED_OPEN:
            {
                if (!m_active)
                {
                    break;
                }
                long conn_idx = evt.Get <long>(0);
                if (!m_connectes.Contains(conn_idx))
                {
                    m_connectes.Add(conn_idx);
                }
            }
            break;

            case ClientEventID.NET_CONNECTED_CLOSE:
            {
                if (!m_active)
                {
                    break;
                }
                long conn_idx = evt.Get <long>(0);
                m_connectes.Remove(conn_idx);
            }
            break;

            case ClientEventID.SWITCH_PRESSURE:
            {
                ePressureType type     = evt.Get <ePressureType>(0);
                bool          is_start = evt.Get <bool>(1);
                if (type == ePressureType.Login && is_start)
                {
                    m_pressure_info = evt.Get <sPressureLoginInfo>(2);
                    this.Start();
                }
                else
                {
                    this.Stop();
                }
            }
            break;
            }
        }