Exemplo n.º 1
0
void NFCTeamModule::OnLeaveTeamProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqAckLeaveTeam);

    if (LeaveTeam(nPlayerID, NFINetModule::PBToNF(xMsg.team_id())))
    {

        NFMsg::ReqAckLeaveTeam xAck;
        *xAck.mutable_team_id() = xMsg.team_id();

        NFGUID xTeam = NFINetModule::PBToNF(xMsg.team_id());

        NFMsg::TeamInfo xTeamInfo;
        if (!GetTeamInfo(nPlayerID, xTeam, xTeamInfo))
        {
            xAck.mutable_xteaminfo()->CopyFrom(xTeamInfo);
        }

        m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_LEAVE_TEAM, xAck, nSockIndex, nPlayerID);

        BroadcastMsgToTeam(nPlayerID, xTeam, NFMsg::EGMI_ACK_LEAVE_TEAM, xAck);
    }
    else
    {
        NFMsg::ReqAckLeaveTeam xAck;
        *xAck.mutable_team_id() = NFINetModule::NFToPB(NFGUID());

        m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_LEAVE_TEAM, xAck, nSockIndex, nPlayerID);
    }
}
Exemplo n.º 2
0
void NFCTeamModule::OnCreateTeamProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
	CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqAckCreateTeam);

	std::string strRoleName ;
	int nLevel = 0;
	int nJob = 0;
	int nDonation= 0;
	int nVIP= 0;

	NFGUID xTeam = CreateTeam(nPlayerID, NFINetModule::PBToNF(xMsg.team_id()), strRoleName, strRoleName, nLevel, nJob, nDonation, nVIP);

	if (!xTeam.IsNull())
	{
		NFMsg::ReqAckCreateTeam xAck;
		*xAck.mutable_team_id() = NFINetModule::NFToPB(xTeam);

        NFMsg::TeamInfo xTeamInfo;
        if (!GetTeamInfo(nPlayerID, xTeam, xTeamInfo))
        {
            xAck.mutable_xteaminfo()->CopyFrom(xTeamInfo);
            m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_TEAM, xAck, nSockIndex, nPlayerID);
            return;
        }
    }

    NFMsg::ReqAckCreateTeam xAck;
    *xAck.mutable_team_id() = NFINetModule::NFToPB(xTeam);

    m_pNetModule->SendMsgPB(NFMsg::EGMI_ACK_CREATE_TEAM, xAck, nSockIndex, nPlayerID);
}
Exemplo n.º 3
0
std::wstring TeamService::GetTeamName( const std::string& tid )
{
	assert(nbase::MessageLoop::current()->ToUIMessageLoop());

	std::wstring tname;

	std::map<std::string,std::string>::iterator it = tid_tname_pair_.find(tid);
	if(it == tid_tname_pair_.end())
	{
		tname = nbase::UTF8ToUTF16(tid);

		GetTeamInfo(tid);
	}
	else
	{
		tname = nbase::UTF8ToUTF16(it->second);
	}

	return tname;
}
Exemplo n.º 4
0
void NFCTeamModule::OnOprTeamMemberProcess(const NFSOCK nSockIndex, const int nMsgID, const char* msg, const uint32_t nLen)
{
    CLIENT_MSG_PROCESS( nMsgID, msg, nLen, NFMsg::ReqAckOprTeamMember);

    NFMsg::ReqAckOprTeamMember::EGTeamMemberOprType eOprType = xMsg.type();
    switch (eOprType)
    {
    case NFMsg::ReqAckOprTeamMember::EGAT_KICKOUT:
        KickTeamMmember(nPlayerID, NFINetModule::PBToNF(xMsg.team_id()), NFINetModule::PBToNF(xMsg.member_id()));
        break;
    default:
        break;
    }

    NFGUID xTeam = NFINetModule::PBToNF(xMsg.team_id());
    NFMsg::TeamInfo xTeamInfo;
    if (!GetTeamInfo(nPlayerID, xTeam, xTeamInfo))
    {
        xMsg.mutable_xteaminfo()->CopyFrom(xTeamInfo);
    }

    BroadcastMsgToTeam(nPlayerID, xTeam, NFMsg::EGMI_ACK_OPRMEMBER_TEAM, xMsg);
}
Exemplo n.º 5
0
int     CZiMainFrame::OnClickVerifyResponse(WPARAM wp, LPARAM lp)
{
	Assert(lp);
	VerifyScQuery_t    * pVerifyq = (VerifyScQuery_t *)lp;
	VerifyCcResponse_t   verifyp;

	if(wp == 1)
	{
		if(pVerifyq->nRecvType == Type_ImcFriend)
		{
			Assert(pVerifyq->pSenderNetQInfo && 
				pVerifyq->pSenderNetQInfo->nItemType == Type_ImcFriend);
			CNodeList * pTeamInfo = GetTeamInfo(Team_DefaultNameT);

			Assert(pTeamInfo);
			if(pTeamInfo) 
			{
				pVerifyq->pSenderNetQInfo->strAdminName = Team_DefaultNameA;
				AddItem(pVerifyq->pSenderNetQInfo, pTeamInfo);
			}
		}
	}

	// Msg_ScQueryVerify -> Msg_CsResponseVerify ..??
	verifyp.bIsAgree     = wp == 1 ? 1 : 0;
	verifyp.nSenderId    = MagicId_t(Msg_CsResponseVerify, pVerifyq->nRecvType, pVerifyq->nRecverId);
	verifyp.nRecverId    = MagicId_F(Msg_CsResponseVerify, pVerifyq->nSenderId);
	verifyp.szSenderName = pVerifyq->szRecverNamex;
	verifyp.szRecverName = pVerifyq->szSenderNamex;
	verifyp.nRecvType    = pVerifyq->nRecvType;
	verifyp.pSenderLocalRInfo = GetNodeData(pVerifyq->nRecverId);

	Assert(m_pMainMsger);
	m_pMainMsger->SendImMessage(Msg_CsResponseVerify, (LPARAM)&verifyp, sizeof(verifyp));
	m_pMainMsger->FreeDataEx(Msg_ScQueryVerify, pVerifyq);
	return 0;
}
Exemplo n.º 6
0
int     CZiMainFrame::HandleNetMessage(int nMsg, void * pNetData)
{
	// 未处理添加群组 ... ???
	Assert(pNetData);
	int  nRet  = 0;
	bool bFree = TRUE;

	switch(nMsg)
	{
	case Msg_ScQueryVerify:
		{
			// 显示验证请求框, 交给用户操作. 
			// 还需要显示请求者的信息, 未实现 ... ???
			VerifyScQuery_t * pVerifyQuery = (VerifyScQuery_t*)pNetData;
			char              szText[1024] = {0};
			if (m_itemSelfInfo.nAddFriendType == 1) {
				sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
					"'%s'(%d) 请求为好友, 验证信息: '%s'", 
					pVerifyQuery->szSenderNamex, 
					pVerifyQuery->nSenderId, 
					pVerifyQuery->szVerifyDatax);
				CNotifyWindow::MessageBoxX(m_hWnd, _T("验证消息"), 
					CA2T(szText), _T("同意"), _T("不同意"), 
					Msg_InQueryVerify, pVerifyQuery);
			}
			else {
				sprintf_s(szText, sizeof(szText)/sizeof(szText[0]), 
					"'%s' 将您添加为好友,附加信息: %s", 
					pVerifyQuery->szSenderNamex, 
					pVerifyQuery->szVerifyDatax);
				CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
			}
			bFree = FALSE;
		}
		break;

	case Msg_ScResponseVerify: 
		{
			// 显示验证回复框, 通知用户. 
			// 如果失败可以不回复对方. 
			VerifyCcResponse_t * pVerifyResp  = (VerifyCcResponse_t*)pNetData;
			char szText[1024] = {0};
			if (pVerifyResp->nAddFriendType == 1) {
				sprintf_s(szText, sizeof(szText), "'%s' %s  加您为好友",
					pVerifyResp->szSenderName2, 
					(pVerifyResp->bIsAgree ? "同意" : "不同意"));
				CNotifyWindow::MessageBoxX(m_hWnd, _T("验证消息"), CA2T(szText));

				if(pVerifyResp->nRecvType == Type_ImcFriend)
				{
					Assert(pVerifyResp->pSenderNetRInfo && 
						pVerifyResp->pSenderNetRInfo->nItemType == Type_ImcFriend);
					CNodeList * pTeamInfo = GetTeamInfo(Team_DefaultNameT);

					Assert(pTeamInfo);
					if(pTeamInfo) AddItem(pVerifyResp->pSenderNetRInfo, pTeamInfo);
				}
			}
			else {
				sprintf_s(szText, sizeof(szText), "添加好友 '%s' %s", 
					pVerifyResp->szRecverName2, 
					pVerifyResp->bIsAgree? "成功" : "失败");
				CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(szText));
			}
			bFree = TRUE;
		}
		break;

	case Msg_ScTextChat:
		{
			// 没有聊天对话框, 通知用户.  
			// 显示聊天对话框. 
			// 将消息显示到消息框中. ???
			ChatCcTextData_t * pChatText   = (ChatCcTextData_t*)pNetData;
			CChatDialog      * pChatDialog = 0;
            if (pChatText->nRecvType == Type_ImcFriend || pChatText->nRecvType == Type_ImcFriendX) { //好友消息
                CreateChatDailog(pChatText->nSenderId, &pChatDialog);
                if(pChatDialog)  // 可能无效. 
                {
                    pChatDialog->OnTextMsgShow(pChatText);
                    pChatDialog->ActiveWindow();
                }
            }
            else { //群消息
                CreateChatDailog(pChatText->nRecverId, &pChatDialog);
                if (pChatDialog) {
                    pChatDialog->OnTextMsgShow(pChatText);
                    pChatDialog->ActiveWindow();
                }
            }
            bFree = TRUE;
		}
		break;
    case Msg_ScDelFriend:
        {
            //TODO 执行删除好友的操作
			bool popMsgBox = false;
			DelFriendItem *pDelFriend = (DelFriendItem *)pNetData;
			char  tsText[1024] = {0};
			int nDelId = IdNetToLocal(pDelFriend->type, pDelFriend->nDelId);
			int nSendId = IdNetToLocal(Type_ImcFriend, pDelFriend->nSendId);
			//TODO
			if (pDelFriend->type == Type_ImcTeam) {
			}
			else if (pDelFriend->type == Type_ImcFriend) {
				if (nDelId == m_itemSelfInfo.nId) {
					if (pDelFriend->succ == 0) {
						sprintf_s(tsText, sizeof(tsText)/sizeof(tsText[0]), "%s 将您移除好友列表", ((pDelFriend->strSendName.c_str())));
						popMsgBox = true;
					}
				}
				else {
					sprintf_s(tsText, sizeof(tsText)/sizeof(tsText[0]), "删除好友 %s %s", ((pDelFriend->strdelName.c_str())), (pDelFriend->succ == 0 ? "成功" : "失败"));
					popMsgBox = true;
				}		
			}
			else if (pDelFriend->type == Type_ImcFriendX) {
			}
			else if (pDelFriend->type == Type_ImcGroup) {
				if (nSendId == m_itemSelfInfo.nId) {
					sprintf_s(tsText, sizeof(tsText)/sizeof(tsText[0]), "删除群 %s %s", ((pDelFriend->strdelName.c_str())), (pDelFriend->succ == 0 ? "成功" : "失败"));
					popMsgBox = true;
				}
				else if (pDelFriend->succ == 0) {
				    sprintf_s(tsText, sizeof(tsText)/sizeof(tsText[0]), "%s 将您移除群 %s", ((pDelFriend->strSendName.c_str())), (pDelFriend->strdelName.c_str()));
					popMsgBox = true;
				}
			}
			else {
			}
			if (popMsgBox) {
				CNotifyWindow::MessageBoxX(m_hWnd, _T("通知"), CA2T(tsText));
			}
			bFree = TRUE;
        }
        break;
	case Msg_ScAddGroupVerify:
		handlerAddGroupVerify((AddGroupInfo_t *)pNetData);
		break;
	}

	if(bFree) m_pMainMsger->FreeDataEx(nMsg, pNetData);
	return nRet;
}