Esempio n. 1
0
void CLoginConn::_HandleMsgServInfo(CImPdu* pPdu)
{
	msg_serv_info_t* pMsgServInfo = new msg_serv_info_t;
    IM::Server::IMMsgServInfo msg;
    msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength());
    
	pMsgServInfo->ip_addr1 = msg.ip1();	// 电信IP
	pMsgServInfo->ip_addr2 = msg.ip2();	// 网通IP
	pMsgServInfo->port = msg.port();
	pMsgServInfo->max_conn_cnt = msg.max_conn_cnt();
	pMsgServInfo->cur_conn_cnt = msg.cur_conn_cnt();
	pMsgServInfo->hostname = msg.host_name();

	// 当前msg_server用户数
	g_msg_serv_info.insert(make_pair(m_handle, pMsgServInfo));

	// 总共用户数
	g_total_online_user_cnt += pMsgServInfo->cur_conn_cnt;

	// 电信ip, 网通ip、端口,允许最大连接数,当前连接数
	log("MsgServInfo, ip_addr1=%s, ip_addr2=%s, port=%d, max_conn_cnt=%d, cur_conn_cnt=%d, "\
		"hostname: %s. ",
		pMsgServInfo->ip_addr1.c_str(), pMsgServInfo->ip_addr2.c_str(), pMsgServInfo->port,pMsgServInfo->max_conn_cnt,
		pMsgServInfo->cur_conn_cnt, pMsgServInfo->hostname.c_str());
}
Esempio n. 2
0
void CLoginConn::_HandleMsgServInfo(CImPdu* pPdu)
{
	log("enter[%s]", __FUNCTION__);

	msg_serv_info_t* pMsgServInfo = new msg_serv_info_t;
    IM::Server::IMMsgServInfo msg;
    msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength());
    
	pMsgServInfo->ip_addr1 = msg.ip1();
	pMsgServInfo->ip_addr2 = msg.ip2();
	pMsgServInfo->port = msg.port();
	pMsgServInfo->max_conn_cnt = msg.max_conn_cnt();
	pMsgServInfo->cur_conn_cnt = msg.cur_conn_cnt();
	pMsgServInfo->hostname = msg.host_name();
	//此处保存Msg_Sever的信息
	g_msg_serv_info.insert(make_pair(m_handle, pMsgServInfo));

	//???在线并发总人数是将当前的消息服务器的总人数直接加上?
	g_total_online_user_cnt += pMsgServInfo->cur_conn_cnt;

	log("MsgServInfo, ip_addr1=%s, ip_addr2=%s, port=%d, max_conn_cnt=%d, cur_conn_cnt=%d, "\
		"hostname: %s. ",
		pMsgServInfo->ip_addr1.c_str(), pMsgServInfo->ip_addr2.c_str(), pMsgServInfo->port,pMsgServInfo->max_conn_cnt,
		pMsgServInfo->cur_conn_cnt, pMsgServInfo->hostname.c_str());
	log("leave[%s]", __FUNCTION__);

}
Esempio n. 3
0
void CLoginConn::_HandleMsgServInfo(CImPdu* pPdu)
{
    msg_serv_info_t* pMsgServInfo = new msg_serv_info_t;
    IM::Server::IMMsgServInfo msg;
    msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength());
    
    pMsgServInfo->ip_addr1 = msg.ip1();
    pMsgServInfo->ip_addr2 = msg.ip2();
    pMsgServInfo->port = msg.port();
    pMsgServInfo->max_conn_cnt = msg.max_conn_cnt();
    pMsgServInfo->cur_conn_cnt = msg.cur_conn_cnt();
    pMsgServInfo->hostname = msg.host_name();
    g_msg_serv_info.insert(make_pair(m_handle, pMsgServInfo));
    log("g_msg_serv_info: %u", g_msg_serv_info.size());
    g_total_online_user_cnt += pMsgServInfo->cur_conn_cnt;

    log("MsgServInfo, ip_addr1=%s, ip_addr2=%s, port=%d, max_conn_cnt=%d, cur_conn_cnt=%d, hostname: %s. ",
        pMsgServInfo->ip_addr1.c_str(), pMsgServInfo->ip_addr2.c_str(), pMsgServInfo->port,pMsgServInfo->max_conn_cnt,
        pMsgServInfo->cur_conn_cnt, pMsgServInfo->hostname.c_str());
}
Esempio n. 4
0
void CLoginServConn::OnConfirm()
{
    log("connect to login server success ");
    m_bOpen = true;
    g_login_server_list[m_serv_idx].reconnect_cnt = MIN_RECONNECT_CNT / 2;

    uint32_t cur_conn_cnt = 0;
    uint32_t shop_user_cnt = 0;
    
    list<user_conn_t> user_conn_list;
    CImUserManager::GetInstance()->GetUserConnCnt(&user_conn_list, cur_conn_cnt);
    char hostname[256] = {0};
    gethostname(hostname, 256);

    IM::Server::IMMsgServInfo msg;
    msg.set_ip1(g_msg_server_ip_addr1);
    msg.set_ip2(g_msg_server_ip_addr2);
    msg.set_port(g_msg_server_port);
    msg.set_max_conn_cnt(g_max_conn_cnt);
    msg.set_cur_conn_cnt(cur_conn_cnt);
    msg.set_host_name(hostname);

    SendPdu(SID_OTHER, CID_OTHER_MSG_SERV_INFO, msg);
}