Пример #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;
            }
        }
Пример #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;
            }
        }
Пример #3
0
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~创建角色~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        /// <summary>
        /// 登陆测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoginPageClick(object sender, EventArgs e)
        {
            this.SetCreateProgress(0, 1);
            if (m_tabLogin_Start.Text == "停止")
            {
                m_tabLogin_Start.Text    = "开始";
                m_tabLogin_Start.Enabled = true;
                EnableTabPage(true, m_tabUser);
                EnableLoginTabPage(true);

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.CreateUser, false);
            }
            else
            {
                sCreateUserInfo info = new sCreateUserInfo();
                info.ip            = this.m_tabUser_IP.Text;
                info.port          = ushort.Parse(this.m_tabUser_Port.Text);
                info.db_name       = this.m_tabUser_DB.Text;
                info.start_id      = long.Parse(this.m_tabUser_StartId.Text);
                info.start_account = long.Parse(this.m_tabUser_StartAccount.Text);
                info.end_account   = long.Parse(this.m_tabUser_EndAccount.Text);
                if (info.start_id < 0)
                {
                    MessageBox.Show("请设置有效的角色起始id", "错误", MessageBoxButtons.OK);
                    return;
                }
                if (info.end_account <= info.start_account || info.start_account < 0)
                {
                    MessageBox.Show("请设置有效的账号范围", "错误", MessageBoxButtons.OK);
                    return;
                }

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

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.CreateUser, true, info);
                m_tabLogin_Start.Enabled = true;
            }
        }
 private void OnGameEvent(GameEvent evt)
 {
     switch (evt.type)
     {
     case ClientEventID.SWITCH_PRESSURE:
     {
         ePressureType type     = evt.Get <ePressureType>(0);
         bool          is_start = evt.Get <bool>(1);
         if (type == ePressureType.CreateUser && is_start)
         {
             m_pressure_info = evt.Get <sCreateUserInfo>(2);
             this.Start();
         }
         else
         {
             this.Stop();
         }
     }
     break;
     }
 }
Пример #5
0
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~移动~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        private void OnMovePageClick(object sender, EventArgs e)
        {
            if (m_tabMove_Start.Text == "停止")
            {
                m_tabMove_Start.Enabled = false;
                ClientNetManager.Instance.CloseAll();
                m_tabMove_Start.Text    = "开始";
                m_tabMove_Start.Enabled = true;
                EnableTabPage(true, m_tabMove);
                EnableMoveTabPage(true);

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Move, false);
            }
            else
            {
                sPressureMoveInfo info = new sPressureMoveInfo();
                info.ip            = this.m_tabMove_IP.Text;
                info.port          = ushort.Parse(this.m_tabMove_Port.Text);
                info.client_count  = ushort.Parse(this.m_tabMove_ClientCount.Text);
                info.move_time     = float.Parse(this.m_tabMove_MoveTime.Text);
                info.start_account = long.Parse(this.m_tabMove_StartAccount.Text);
                ServerConfig.net_info.move_server_ip     = info.ip;
                ServerConfig.net_info.move_server_port   = info.port;
                ServerConfig.net_info.move_client_count  = info.client_count;
                ServerConfig.net_info.move_start_account = info.start_account;

                m_tabMove_Start.Enabled = false;
                EnableTabPage(false, m_tabMove);
                EnableMoveTabPage(false);
                m_pressure_type      = ePressureType.Move;
                m_tabMove_Start.Text = "停止";

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Move, true, info);
                ClientNetManager.Instance.StartConnect(info.ip, info.port, info.client_count, 10);
                m_tabMove_Start.Enabled = true;
            }
        }
Пример #6
0
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~网络~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        /// <summary>
        /// 网络压力
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNetPageClick(object sender, EventArgs e)
        {
            if (m_tabNet_Start.Text == "停止")
            {
                m_tabNet_Start.Enabled = false;
                ClientNetManager.Instance.CloseAll();
                m_tabNet_Start.Text    = "开始";
                m_tabNet_Start.Enabled = true;
                EnableTabPage(true, m_tabNet);
                EnableNetTabPage(true);

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Net, false);
            }
            else
            {
                sPressureNetInfo info = new sPressureNetInfo();
                info.ip                                = this.m_tabNet_IP.Text;
                info.port                              = ushort.Parse(this.m_tabNet_Port.Text);
                info.client_count                      = ushort.Parse(this.m_tabNet_ClientCount.Text);
                info.send_count_per_second             = ushort.Parse(this.m_tabNet_SendCountPerSecond.Text);
                info.send_size_per_packet              = ushort.Parse(this.m_tabNet_SendSizePerSecond.Text);
                ServerConfig.net_info.net_server_ip    = info.ip;
                ServerConfig.net_info.net_server_port  = info.port;
                ServerConfig.net_info.net_client_count = info.client_count;

                m_tabNet_Start.Enabled = false;
                EnableTabPage(false, m_tabNet);
                EnableNetTabPage(false);
                m_pressure_type     = ePressureType.Net;
                m_tabNet_Start.Text = "停止";

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.Net, true, info);
                ClientNetManager.Instance.StartConnect(info.ip, info.port, info.client_count, 5);
                m_tabNet_Start.Enabled = true;
            }
        }
        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.ContainsKey(conn_idx))
                {
                    MoveClient client = new MoveClient();
                    client.Setup(conn_idx, m_pressure_info.start_account + m_connectes.Count);
                    m_connectes.Add(conn_idx, client);
                }
            }
            break;

            case ClientEventID.NET_CONNECTED_CLOSE:
            {
                if (!m_active)
                {
                    break;
                }
                long       conn_idx = evt.Get <long>(0);
                MoveClient client;
                if (m_connectes.TryGetValue(conn_idx, out client))
                {
                }
                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.Move && is_start)
                {
                    m_pressure_info = evt.Get <sPressureMoveInfo>(2);
                    this.Start();
                }
                else
                {
                    this.Stop();
                }
            }
            break;

            case ClientEventID.RECV_DATA:
            {
                if (!m_active)
                {
                    break;
                }
                long       conn_idx = evt.Get <long>(0);
                ushort     header   = evt.Get <ushort>(1);
                ByteArray  data     = evt.Get <ByteArray>(2);
                MoveClient client;
                if (m_connectes.TryGetValue(conn_idx, out client))
                {
                    client.OnNetworkServer(header, data);
                }
            }
            break;
            }
        }
        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.Net && is_start)
                {
                    m_pressure_info = evt.Get <sPressureNetInfo>(2);
                    this.Start();
                }
                else
                {
                    this.Stop();
                }
            }
            break;

            case ClientEventID.RECV_DATA:
            {
                if (!m_active)
                {
                    break;
                }
                long      conn_idx = evt.Get <long>(0);
                ushort    header   = evt.Get <ushort>(1);
                ByteArray data     = evt.Get <ByteArray>(2);
                if (header == gs2c.msg.ENCRYPT)
                {
                    m_had_recv_encrypt = true;
                    PacketBase packet = PacketPools.Get(header);
                    packet.Read(data);
                    GlobalID.ENCRYPT_KEY = (packet as gs2c.EncryptInfo).key;
                    PacketPools.Recover(packet);
                }
            }
            break;
            }
        }