//用户登录失败
bool CAttemperEngineSink::OnDBLogonError(void * pDataBuffer, WORD wDataSize, NTY_DataBaseEvent * pDataBaseEvent)
{
	//效验参数
	ASSERT(pDataBaseEvent->wRequestID==DBR_GP_LOGON_ERROR);
	ASSERT(wDataSize==sizeof(DBR_GP_LogonError));

	//判断在线
	ASSERT(pDataBaseEvent->wIndex<m_pInitParamter->m_wMaxConnect);
	tagConnectItemInfo * pConnectItemInfo=(m_pConnectItemInfo+pDataBaseEvent->wIndex);
	if (pConnectItemInfo->bConnect==FALSE) return true;
	if (pConnectItemInfo->wRoundID!=pDataBaseEvent->wRoundID) return true;

	//变量定义
	CMD_GP_LogonError LogonError;
	DBR_GP_LogonError * pLogonError=(DBR_GP_LogonError *)pDataBuffer;
	pLogonError->szErrorDescribe[CountString(pLogonError->szErrorDescribe)-1]=0;

	//构造数据
	LogonError.lErrorCode=pLogonError->lErrorCode;
	lstrcpyn(LogonError.szErrorDescribe,pLogonError->szErrorDescribe,sizeof(LogonError.szErrorDescribe));
	WORD wDescribeSize=CountString(LogonError.szErrorDescribe);

	//发送数据
	WORD wSendSize=sizeof(LogonError)-sizeof(LogonError.szErrorDescribe)+wDescribeSize;
	m_pITCPSocketEngine->SendData(pDataBaseEvent->wIndex,pDataBaseEvent->wRoundID,MDM_GP_LOGON,
		SUB_GP_LOGON_ERROR,&LogonError,wSendSize);

	//关闭连接
	m_pITCPSocketEngine->ShutDownSocket(pDataBaseEvent->wIndex,pDataBaseEvent->wRoundID);

	return true;
}
Exemple #2
0
//更新存储过程
LONG CDataBaseSink::SPRegisterAccounts(LPCTSTR pszAccounts, LPCTSTR pszPassword, LPCTSTR pszSpreader, WORD wFaceID, BYTE cbGender, DWORD dwClientIP, LPCTSTR pszComputerID)
{
	//效验参数
	ASSERT(pszAccounts!=NULL);
	ASSERT(pszPassword!=NULL);

	//转化地址
	TCHAR szClientIP[16]=TEXT("");
	BYTE * pClientIP=(BYTE *)&dwClientIP;
	_snprintf(szClientIP,sizeof(szClientIP),TEXT("%d.%d.%d.%d"),pClientIP[0],pClientIP[1],pClientIP[2],pClientIP[3]);

	//执行存储过程
	m_UserDataBase->ClearAllParameters();
	m_UserDataBase->SetSPName("GSP_GP_RegisterAccounts");
	m_UserDataBase->AddParamter(TEXT("RETURN_VALUE"),adParamReturnValue,adInteger,4,_variant_t((long)0));
	m_UserDataBase->AddParamter(TEXT("@strAccounts"),adParamInput,adVarChar,CountString(pszAccounts),_variant_t(pszAccounts));
	m_UserDataBase->AddParamter(TEXT("@strPassword"),adParamInput,adChar,CountString(pszPassword),_variant_t(pszPassword));
	m_UserDataBase->AddParamter(TEXT("@strSpreader"),adParamInput,adVarChar,CountString(pszSpreader),_variant_t(pszSpreader));
	m_UserDataBase->AddParamter(TEXT("@nFaceID"),adParamInput,adInteger,sizeof(long),_variant_t((long)wFaceID));
	m_UserDataBase->AddParamter(TEXT("@cbGender"),adParamInput,adInteger,sizeof(long),_variant_t((long)cbGender));
	m_UserDataBase->AddParamter(TEXT("@strClientIP"),adParamInput,adVarChar,CountString(szClientIP),_variant_t(szClientIP));
	m_UserDataBase->AddParamter(TEXT("@strMachineSerial"),adParamInput,adVarChar,CountString(pszComputerID),_variant_t(pszComputerID));
	m_UserDataBase->ExecuteCommand(true);

	return m_UserDataBase->GetReturnValue();
}
Exemple #3
0
//发送按钮
void CShortMessage::OnBnClickedSendShort()
{
    //判断信息
    m_SendMessage.SetFocus();
    if (m_SendMessage.GetWindowTextLength()==0)	return;

    try
    {
        //获取时间
        long int dwNowTime=(long int)time(NULL);

        //判断目标对象
        ASSERT(m_dwTargetUserID!=0L);
        if ((m_pTargetUserItem==NULL)||(m_dwTargetUserID!=m_pTargetUserItem->GetUserData()->dwUserID))
        {
            m_pTargetUserItem=((CRoomViewItem *)m_pParentWnd)->m_ClientUserManager.SearchUserByUserID(m_dwTargetUserID);
            if (m_pTargetUserItem==NULL) m_MessageProxyHelper->InsertSystemString(TEXT("目标玩家已经离开,信息发送失败!"),MS_NORMAL);
            return;
        }

        //获取消息
        CString strBuffer;
        m_SendMessage.GetWindowText(strBuffer);

        //过滤消息
        if (strBuffer.Find(TEXT("{\\rtf"))!=-1) throw TEXT("不能发送非法字符,发送失败!");
        for (int i=strBuffer.GetLength(); i>0; i--)
            if ((strBuffer[i-1]!=TEXT('\n'))&&(strBuffer[i-1]!=TEXT('\r'))&&(strBuffer[i-1]>=-1)&&(strBuffer[i-1]<30)) throw TEXT("不能发送非法字符,发送失败!");

        //发送消息
        CMD_GR_Wisper Wisper;
        Wisper.dwTargetUserID=m_dwTargetUserID;
        Wisper.crFontColor=g_GlobalOption.m_crChatTX;
        Wisper.dwSendUserID=g_GlobalUnits.GetGolbalUserData().dwUserID;
        lstrcpyn(Wisper.szChatMessage,strBuffer,CountArray(Wisper.szChatMessage));
        Wisper.wChatLength=CountString(Wisper.szChatMessage);

        //发送命令
        WORD wSendSize=sizeof(Wisper)-sizeof(Wisper.szChatMessage)+Wisper.wChatLength;
        ((CRoomViewItem *)m_pParentWnd)->m_ClientSocket->SendData(MDM_GR_USER,SUB_GR_USER_WISPER,&Wisper,wSendSize);

        //设置参数
        m_SendMessage.SetWindowText(TEXT(""));
    }
    catch (TCHAR * szErrorMessage) {
        m_MessageProxyHelper->InsertSystemString(szErrorMessage,MS_NORMAL);
    }
    catch (...) {
        m_MessageProxyHelper->InsertSystemString(TEXT("未知异常错误,消息发送失败!"),MS_NORMAL);
    }

    return;
}
Exemple #4
0
//发送坐下失败
void CTableFrame::SendSitFailedPacket(IServerUserItem * pIServerUserItem, LPCTSTR pszFailedDescribe)
{
	//构造数据
	CMD_GR_SitFailed SitFailed;
	memset(&SitFailed,0,sizeof(SitFailed));
	lstrcpyn(SitFailed.szFailedDescribe,pszFailedDescribe,CountArray(SitFailed.szFailedDescribe));

	//发送数据
	WORD wSendSize=sizeof(SitFailed)-sizeof(SitFailed.szFailedDescribe)+CountString(SitFailed.szFailedDescribe);
	m_pIGameServiceFrame->SendData(pIServerUserItem,MDM_GR_USER,SUB_GR_SIT_FAILED,&SitFailed,wSendSize);

	return;
}
//I D 存储过程
LONG CDataBaseSink::SPLogonByUserID(DWORD dwUserID, LPCTSTR pszPassword, DWORD dwClientIP)
{
	//效验参数
	ASSERT(dwUserID!=0L);
	ASSERT(pszPassword!=NULL);

	//转化地址
	TCHAR szClientIP[16]=TEXT("");
	BYTE * pClientIP=(BYTE *)&dwClientIP;
	_snprintf(szClientIP,sizeof(szClientIP),TEXT("%d.%d.%d.%d"),pClientIP[0],pClientIP[1],pClientIP[2],pClientIP[3]);

	//执行存储过程
	m_UserDataBase->ClearAllParameters();
	m_UserDataBase->SetSPName("GSP_GP_LogonByUserID");
	m_UserDataBase->AddParamter(TEXT("RETURN_VALUE"),adParamReturnValue,adInteger,sizeof(long),_variant_t((long)0));
	m_UserDataBase->AddParamter(TEXT("@dwUserID"),adParamInput,adInteger,sizeof(long),_variant_t((long)dwUserID));
	m_UserDataBase->AddParamter(TEXT("@strPassword"),adParamInput,adChar,CountString(pszPassword),_variant_t(pszPassword));
	m_UserDataBase->AddParamter(TEXT("@strClientIP"),adParamInput,adVarChar,CountString(szClientIP),_variant_t(szClientIP));
	m_UserDataBase->ExecuteCommand(true);

	return m_UserDataBase->GetReturnValue();
}
Exemple #6
0
//发送游戏消息
bool __cdecl CTableFrame::SendGameMessage(IServerUserItem * pIServerUserItem, LPCTSTR lpszMessage, WORD wMessageType)
{
	//构造数据包
	CMD_GF_Message Message;
	Message.wMessageType=wMessageType;
	lstrcpyn(Message.szContent,lpszMessage,CountArray(Message.szContent));
	Message.wMessageLength=CountString(Message.szContent);

	//发送数据
	WORD wSendSize=sizeof(Message)-sizeof(Message.szContent)+Message.wMessageLength*sizeof(TCHAR);
	m_pIGameServiceFrame->SendData(pIServerUserItem,MDM_GF_FRAME,SUB_GF_MESSAGE,&Message,wSendSize);

	return true;
}
Exemple #7
0
//发送聊天
bool __cdecl CClientKernel::SendChatMessage(DWORD dwTargetUserID, LPCTSTR pszChatMessage, COLORREF crFontColor)
{
	//效验状态
	if (m_pMeUserItem==NULL) return false;

	//构造数据
	CMD_GF_UserChat UserChat;
	UserChat.crFontColor=crFontColor;
	UserChat.dwTargetUserID=dwTargetUserID;
	UserChat.dwSendUserID=m_pMeUserItem->dwUserID;
	lstrcpyn(UserChat.szChatMessage,pszChatMessage,CountArray(UserChat.szChatMessage));
	UserChat.wChatLength=CountString(UserChat.szChatMessage);

	//发送命令
	WORD wSendSize=sizeof(UserChat)-sizeof(UserChat.szChatMessage)+UserChat.wChatLength;
	SendSocketData(MDM_GF_FRAME,SUB_GF_USER_CHAT,&UserChat,wSendSize);

	return true;
}
//用户登录成功
bool CAttemperEngineSink::OnDBLogonSuccess(void * pDataBuffer, WORD wDataSize, NTY_DataBaseEvent * pDataBaseEvent)
{
	//效验参数
	ASSERT(pDataBaseEvent->wRequestID==DBR_GP_LOGON_SUCCESS);
	ASSERT(wDataSize==sizeof(DBR_GP_LogonSuccess));
	if (wDataSize!=sizeof(DBR_GP_LogonSuccess)) return false;

	//判断在线
	ASSERT(pDataBaseEvent->wIndex<m_pInitParamter->m_wMaxConnect);
	tagConnectItemInfo * pConnectItemInfo=(m_pConnectItemInfo+pDataBaseEvent->wIndex);
	if (pConnectItemInfo->bConnect==FALSE) return true;
	if (pConnectItemInfo->wRoundID!=pDataBaseEvent->wRoundID) return true;

	//构造数据
	BYTE cbBuffer[SOCKET_PACKAGE];
	CMD_GP_LogonSuccess * pCMDLogonSuccess=(CMD_GP_LogonSuccess *)cbBuffer;
	DBR_GP_LogonSuccess * pDBRLogonSuccess=(DBR_GP_LogonSuccess *)pDataBuffer;
	pCMDLogonSuccess->cbGender=pDBRLogonSuccess->cbGender;
	pCMDLogonSuccess->cbMember=pDBRLogonSuccess->cbMember;
	pCMDLogonSuccess->wFaceID=pDBRLogonSuccess->wFaceID;
	pCMDLogonSuccess->dwUserID=pDBRLogonSuccess->dwUserID;
	pCMDLogonSuccess->dwGroupID=pDBRLogonSuccess->dwGroupID;
	pCMDLogonSuccess->dwExperience=pDBRLogonSuccess->dwExperience;
	pCMDLogonSuccess->dwUserRight=pDBRLogonSuccess->dwUserRight;
	pCMDLogonSuccess->dwMasterRight=pDBRLogonSuccess->dwMasterRight;

	//叠加数据
	CSendPacketHelper SendPacket(cbBuffer+sizeof(CMD_GP_LogonSuccess),sizeof(cbBuffer)-sizeof(CMD_GP_LogonSuccess));
	SendPacket.AddPacket(pDBRLogonSuccess->szAccounts,CountString(pDBRLogonSuccess->szAccounts),DTP_USER_ACCOUNTS);
	SendPacket.AddPacket(pDBRLogonSuccess->szPassWord,CountString(pDBRLogonSuccess->szPassWord),DTP_USER_PASS);

	//社团信息
	if (pDBRLogonSuccess->dwGroupID!=0L)
	{
		ASSERT(pDBRLogonSuccess->szGroupName[0]!=0);
		SendPacket.AddPacket(pDBRLogonSuccess->szGroupName,CountString(pDBRLogonSuccess->szGroupName),DTP_USER_GROUP_NAME);
	}
	
	//站点主页
	if (m_pInitParamter->m_szMainPage[0]!=0)
	{
		SendPacket.AddPacket(m_pInitParamter->m_szMainPage,CountString(m_pInitParamter->m_szMainPage),DTP_STATION_PAGE);
	}

	//发送登录结果
	WORD wIndex=pDataBaseEvent->wIndex;
	WORD wRoundID=pDataBaseEvent->wRoundID;
	WORD wSendSize=sizeof(CMD_GP_LogonSuccess)+SendPacket.GetDataSize();
	m_pITCPSocketEngine->SendData(wIndex,wRoundID,MDM_GP_LOGON,SUB_GP_LOGON_SUCCESS,cbBuffer,wSendSize);

	//列表配置
	CMD_GP_ListConfig ListConfig;
	ListConfig.bShowOnLineCount=TRUE;
	m_pITCPSocketEngine->SendData(wIndex,wRoundID,MDM_GP_SERVER_LIST,SUB_GP_LIST_CONFIG,&ListConfig,sizeof(ListConfig));

	//发送游戏列表
	m_ServerList.SendGameTypeList(wIndex,wRoundID);
	m_ServerList.SendGameKindList(wIndex,wRoundID);
	m_ServerList.SendGameStationList(wIndex,wRoundID);
	m_ServerList.SendGameServerList(wIndex,wRoundID);

	//发送登录完成
	m_pITCPSocketEngine->SendData(wIndex,wRoundID,MDM_GP_LOGON,SUB_GP_LOGON_FINISH);

	//关闭连接
	m_pITCPSocketEngine->ShutDownSocket(wIndex,wRoundID);

	return true;
}