本文整理汇总了C++中UserSession类的典型用法代码示例。如果您正苦于以下问题:C++ UserSession类的具体用法?C++ UserSession怎么用?C++ UserSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMail
bool MailService::sendMail(DWORD h,Cmd::Session::t_sendMail_SceneSession & sm)
{
if (0==sm.mail.toID && 0==strncmp("",sm.mail.toName,MAX_NAMESIZE))
{
Zebra::logger->error("[邮件]sendMoneyMail 收件人为空 fromName=%s money=%u text=%s type=%u",sm.mail.fromName,sm.mail.sendMoney,sm.mail.text,sm.mail.type);
return false;
}
connHandleID handle = (connHandleID)h;
if ((connHandleID)-1 == handle)
{
Zebra::logger->error("[邮件]sendMail: 无效的数据库句柄");
Zebra::logger->error("[邮件]%s->%s 丢失 money=%u item=%s",sm.mail.fromName,sm.mail.toName,sm.mail.sendMoney,sm.item.object.strName);
return false;
}
DWORD retcode = SessionService::dbConnPool->exeInsert(handle,"`MAIL`",mail_define,(const BYTE *)&sm.mail);
if ((DWORD)-1 == retcode)
{
Zebra::logger->error("[邮件]sendMail: 插入新邮件数据库出错 retcode=%d",retcode);
Zebra::logger->error("[邮件]%s->%s 丢失 money=%u item=%s",sm.mail.fromName,sm.mail.toName,sm.mail.sendMoney,sm.item.object.strName);
return false;
}
newMailMap[sm.mail.toID].insert(retcode);
UserSession * toUser = UserSessionManager::getInstance()->getUserSessionByName(sm.mail.toName);
if (toUser)
{
Cmd::stNotifyNewMail n;
toUser->sendCmdToMe(&n,sizeof(n));
}
return true;
}
示例2: memcpy
/**
* \brief 发送私聊消息给好友,如果对方不在则存为离线消息
* \param pCmd 聊天消息
* \param cmdLen 消息长度
* \return
*/
void CRelationManager::sendPrivateChatToFriend(const Cmd::stChannelChatUserCmd *pCmd,const DWORD cmdLen)
{
//rwlock.rdlock();
CRelation *rel = (CRelation *)getEntryByName(pCmd->pstrName);
if (rel)
{
BYTE buf[x_socket::MAX_DATASIZE];
Cmd::stChannelChatUserCmd *chatCmd;
chatCmd = (Cmd::stChannelChatUserCmd *)buf;
memcpy(chatCmd,pCmd,cmdLen,sizeof(buf));
strncpy(chatCmd->pstrName,user->name,MAX_NAMESIZE);
if (rel->isOnline())
{
UserSession *pUser = UserSessionManager::getInstance()->getUserByID(rel->id);
if (pUser) pUser->sendCmdToMe(chatCmd,cmdLen);
}
else
{
COfflineMessage::writeOfflineMessage(chatCmd->dwType,rel->id,chatCmd,cmdLen);
}
}
//rwlock.unlock();
}
示例3: setErrorResponse
void GamesInsert::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
if (pUserSession == NULL) {
setErrorResponse(response, 1021, "token are not found");
return;
} else if (!pUserSession->isAdmin()) {
setErrorResponse(response, 1022, "this method only for admin");
return;
}
QUrlQuery urlQuery(req->url());
QString name = urlQuery.queryItemValue("name");
if (name.isEmpty()) {
setErrorResponse(response, 1055, "Parameter name are not found or it is empty");
return;
}
QSqlQuery query(*db);
query.prepare("INSERT INTO backend_games(name) VALUES(:name)");
query.bindValue(":name", name);
if (query.exec()) {
response["result"] = QString("ok");
response["id"] = query.lastInsertId().toInt();
} else {
setErrorResponse(response, 1056, query.lastError().text());
return;
}
};
示例4: sendChatToMyFriend
/**
* \brief 发送聊天消息给自己的所有简单社会关系,如果不在线则存为离线消息
* \param pCmd 聊天消息
* \param cmdLen 消息长度
*/
void CRelationManager::sendChatToMyFriend(const Cmd::stChannelChatUserCmd *pCmd,const DWORD cmdLen)
{
//rwlock.rdlock();
user->sendCmdToMe(pCmd,cmdLen); // 转发一条消息给自己,以免看不到自己的聊天记录
for(zEntryName::hashmap::iterator it=zEntryName::ets.begin();it!=zEntryName::ets.end();it++)
{
CRelation *temp = (CRelation *)it->second;
if (temp && (temp->type != Cmd::RELATION_TYPE_BAD)&& (temp->type != Cmd::RELATION_TYPE_ENEMY))
{
if (temp->online)
{
UserSession *pUser = UserSessionManager::getInstance()->getUserByID(temp->id);
if (pUser) pUser->sendCmdToMe(pCmd,cmdLen);
}
else
{
if (Cmd::CHAT_TYPE_FRIEND_AFFICHE == pCmd->dwChannelID)
{
COfflineMessage::writeOfflineMessage(pCmd->dwType,user->id,pCmd,cmdLen);
}
}
}
}
//rwlock.unlock();
}
示例5: MSG_Handler_Reminder_REQ
/*****************************************************
MSG_Handler_CalledBank_REQ
*****************************************************/
void MSG_Handler_Reminder_REQ ( ServerSession * pServerSession, MSG_BASE * pMsg, WORD wSize )
{
UserSession * pSession = ( UserSession * ) pServerSession;
{
UserPacket & user = pSession->GetUserPacket();
user.GetProtocol() = MAKEDWORD( Games_Protocol, Reminder_REQ );
user.ToPrint();
g_AgentServer->SendToGameServer( (BYTE*)&user, user.GetPacketSize() );
}
}
示例6: setErrorResponse
void AdminUserUpdate::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
if (pUserSession == NULL) {
setErrorResponse(response, 1074, "token are not found");
return;
} else if (!pUserSession->isAdmin()) {
setErrorResponse(response, 1075, "this method only for admin");
return;
}
};
示例7: FromClientToAgent_StartGame_REQ
/************************************************
FromClientToAgent_StartGame_REQ
************************************************/
void FromClientToAgent_StartGame_REQ ( ServerSession * pServerSession, MSG_BASE * pMsg, WORD wSize ) {
UserSession * pSession = ( UserSession * ) pServerSession;
{
UserPacket pack = pSession->GetUserPacket();
pack.GetProtocol() = MAKEDWORD( Games_Protocol, StartGame_REQ );
pack.GetReady() = 1;
pack.ToPrint();
g_AgentServer->SendToGameServer( (BYTE*)&pack, pack.GetPacketSize() );
}
}
示例8: CreateClientSideAcceptedObject
// 客户端
NetworkObject * CreateClientSideAcceptedObject() {
printf("[LoginServer::CreateClientSideAcceptedObject]: Alloc UserSession.\n");
UserSession * obj = LoginFactory::Instance()->AllocUserSession();
if ( obj == NULL) {
printf("\nLoginFactory::Instance()->AllocTempUserSession() Fail.\n");
return NULL;
}
obj->Init();
return (NetworkObject *)(obj);
}
示例9: MSG_Handler_QuitTable_REQ
void MSG_Handler_QuitTable_REQ ( ServerSession * pServerSession, MSG_BASE * pMsg, WORD wSize )
{
DEBUG_MSG( LVL_DEBUG, "QuitTable_REQ to recv: %s \n", (char*) pMsg );
UserSession * pSession = ( UserSession * ) pServerSession;
{
UserPacket & user = pSession->GetUserPacket();
user.GetProtocol() = MAKEDWORD( Games_Protocol, QuitTable_REQ );
user.ToPrint();
g_AgentServer->SendToGameServer( (BYTE*)&user, user.GetPacketSize() );
}
}
示例10: sendCmdToAll
bool SessionChannel::sendCmdToAll(const void *cmd,int len)
{
UserSession * user = 0;
for (std::list<DWORD>::iterator it=userList.begin(); it!=userList.end(); it++)
{
user = UserSessionManager::getInstance()->getUserByTempID(*it);
if (user)
{
user->sendCmdToMe(cmd,len);
}
}
return true;
}
示例11: sendToOthers
bool SessionChannel::sendToOthers(UserSession *pUser,const Cmd::stChannelChatUserCmd *cmd,DWORD len)
{
UserSession * user = 0;
for (std::list<DWORD>::iterator it=userList.begin(); it!=userList.end(); it++)
{
user = UserSessionManager::getInstance()->getUserByTempID(*it);
if (user && user!=pUser)
{
user->sendCmdToMe(cmd,len);
}
}
return true;
}
示例12: parseChangeGS
void GateGameClient::parseChangeGS(google::protobuf::Message* p, pb_flag_type flag)
{
message::MsgDB2GTChangeGS* msg = static_cast<message::MsgDB2GTChangeGS*>(p);
UserSession* pksession = gGTUserMgr.getUserSession(flag);
if (msg && pksession)
{
GateGameClient* pkNew = gGTGameMgr.getGameClient(msg->gameserverid());
if (!pkNew)
{
pksession->setClose();
Mylog::log_server(LOG_ERROR, "change server not found the gmae server [%u]", msg->gameserverid());
}else
{
//切换到目标图的GS上
removePlayer( pksession->getTrans());
account_type a = gGTUserMgr.getAccount(pksession->getTrans());
if (a != INVALID_ACCOUNT)
{
pksession->setGSid(msg->gameserverid());
pkNew->addNewPlayer(pksession->getTrans(), gGTUserMgr.getAccount(pksession->getTrans()));
}else
{
pksession->setClose();
Mylog::log_server(LOG_ERROR, "change server not found the Account ");
}
}
}
}
示例13: parseGameMsg
void GateGameClient::parseGameMsg(google::protobuf::Message* p, pb_flag_type flag)
{
UserSession* pksession = gGTUserMgr.getUserSession(flag);
if (pksession)
{
pksession->sendPBMessage(p, flag);
//Mylog::log_player(LOG_DEBUG, "Game Server Send Msg[%s] to user [%u]", p->GetTypeName().c_str(), flag);
}
else
{
//Mylog::log_server(LOG_DEBUG, "send[%s] msg failed, can not find session id[%u]", p->GetTypeName().c_str(), flag);
}
}
示例14: OnError
void BooterServer::OnError(UserSession &sender)
{
LogEvent("BooterServer: OnError()!");
// Mark the failed User Session as out-of-date
sender.setSessionOutdated();
}
示例15: OnClientDisconnected
void BooterServer::OnClientDisconnected(UserSession &sender)
{
LogEvent("BooterServer: OnClientDisconnected()");
// Mark the disconnected User Session as out-of-date
sender.setSessionOutdated();
}