• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UserSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中UserSession的典型用法代码示例。如果您正苦于以下问题:C++ UserSession类的具体用法?C++ UserSession怎么用?C++ UserSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UserSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:edolphin-ydf,项目名称:hydzhengtu,代码行数:35,代码来源:MailService.cpp


示例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();
}
开发者ID:adan830,项目名称:gameserver-2,代码行数:32,代码来源:RelationManager.cpp


示例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;
	}	
};
开发者ID:ctfight,项目名称:jury,代码行数:29,代码来源:games_insert.cpp


示例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();
}
开发者ID:adan830,项目名称:gameserver-2,代码行数:31,代码来源:RelationManager.cpp


示例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() );
    }
}
开发者ID:hujb1983,项目名称:OldGame,代码行数:13,代码来源:Handler_Reminder.cpp


示例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;
	}
};
开发者ID:ctfight,项目名称:jury,代码行数:10,代码来源:admin_userupdate.cpp


示例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() );
    }
}
开发者ID:hujb1983,项目名称:DouDiZhu,代码行数:14,代码来源:Handler_StartGame.cpp


示例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);
}
开发者ID:syalr,项目名称:login_public,代码行数:13,代码来源:LoginServer.cpp


示例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() );
    }
}
开发者ID:hujb1983,项目名称:OldGame,代码行数:12,代码来源:Handler_QuitTable.cpp


示例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;
}
开发者ID:zhutaorun,项目名称:unitygame,代码行数:13,代码来源:SessionChat.cpp


示例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;
}
开发者ID:zhutaorun,项目名称:unitygame,代码行数:13,代码来源:SessionChat.cpp


示例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 ");
			}
		}
	}
}
开发者ID:kingstop,项目名称:crashmo,代码行数:29,代码来源:game_client.cpp


示例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);
	}
    
}
开发者ID:kingstop,项目名称:crashmo,代码行数:14,代码来源:game_client.cpp


示例14: OnError

    void BooterServer::OnError(UserSession &sender)
    {
        LogEvent("BooterServer: OnError()!");

        // Mark the failed User Session as out-of-date
        sender.setSessionOutdated();
    }
开发者ID:ixc-software,项目名称:lucksi,代码行数:7,代码来源:BooterServer.cpp


示例15: OnClientDisconnected

    void BooterServer::OnClientDisconnected(UserSession &sender)
    {
        LogEvent("BooterServer: OnClientDisconnected()");

        // Mark the disconnected User Session as out-of-date
        sender.setSessionOutdated();
    }
开发者ID:ixc-software,项目名称:lucksi,代码行数:7,代码来源:BooterServer.cpp


示例16: SendToClient

// User Server;
BOOL LoginServer::SendToClient( BYTE * pMsg, WORD wSize )
{
	MSG_BASE_FORWARD * pBase = (MSG_BASE_FORWARD *) pMsg;
	
	WORD wIndex = pBase->m_wParameter;
	if ( wIndex == 0 ) {
		return FALSE;	
	}
	
	UserSession * pSession = m_pUserSession[wIndex];
	if ( pSession != NULL ) {
		WORD sendSize =  wSize - sizeof(MSG_BASE_FORWARD);
		BYTE * sendMsg = (BYTE *) ( pBase);
		sendMsg += sizeof(MSG_BASE_FORWARD);
		pSession->Send(sendMsg, sendSize);
	}
}
开发者ID:syalr,项目名称:login_public,代码行数:18,代码来源:LoginServer.cpp


示例17: FromAgentToGame_Offline_BRD

/*****************************************************
    FromAgentToGame_Offline_BRD
*****************************************************/
void FromAgentToGame_Offline_BRD ( TemplateServerSession * pServerSession, MSG_BASE * pMsg, WORD wSize )
{
    DEBUG_MSG( LVL_DEBUG, "Offline_BRD to recv: %s \n", pMsg );

    JsonMap js_map;
    if ( js_map.set_json( (char *) pMsg ) == -1 ) {
        return;
    }

    int _userkey(0);
    js_map.ReadInteger( "userkey",  _userkey );

    UserSession * pSession = NULL;
    pSession = g_AgentServer->GetUserSession( _userkey );
    if ( pSession ) {
        pSession->LeaveGame();
    }
}
开发者ID:hujb1983,项目名称:DouDiZhu,代码行数:21,代码来源:Handler_Offline.cpp


示例18: LOG_INFO

void Seq::attachAndDetachThread()
{
	LOG_INFO("Attach and detach thread");
	JNIEnv* env;
	UserSession* us = UserSession::getInstance();
	int getEnvStat = (us->getVM())->GetEnv((void **)&env, JNI_VERSION_1_6);
	if(getEnvStat == JNI_EDETACHED)
	{
		LOG_INFO("GetEnv: not attached");
		if((us->getVM())->AttachCurrentThread(&env, NULL) != 0){
			LOG_INFO("Failed to attach");
		}
	}else if(getEnvStat == JNI_OK){
		
	}else if(getEnvStat == JNI_EVERSION){
		LOG_INFO("GetEnv: version not supported");
	}
	for(int i = 0; i < NUMBER_OF_PADS; ++i)
	{
		if(p[i].note[seqI]){
			env->CallStaticVoidMethod(sampleTriggerMethodClass, sampleTriggerMethodID, i);
			if(padState[i].state){
				padState[i].increment = 0;
			}else if(!padState[i].state){
				padState[i].state = true;
				padState[i].increment = 0;
			}
		}	
		if(padState[i].state){
			if(padState[i].increment >= PAD_STATE_INCR){
				padState[i].increment = 0;
				padState[i].state = false;
			}else{
				++padState[i].increment; 
			}
		}
	}
	if(sequencerRunning)
		env->CallStaticVoidMethod(sampleTriggerMethodClass, metronomeMethodID, seqI);
	if(env->ExceptionCheck()){
		env->ExceptionDescribe();
	}
	(us->getVM())->DetachCurrentThread();
}
开发者ID:EtherBit,项目名称:The-Beat-Bang-Drum-Machine,代码行数:44,代码来源:seq.cpp


示例19: FromLobbyToAgent_Onlines_ANC

/*******************************************************
	FromLobbyToAgent_Onlines_ANC
******************************************************/
void FromLobbyToAgent_Onlines_ANC ( ServerSession * pServerSession, MSG_BASE * pMsg, WORD wSize ) {

    DEBUG_MSG( LVL_DEBUG, "Onlines_ANC to client: %s \n",(char *) pMsg );

    JsonMap js_map;
    if ( js_map.set_json( (char*) pMsg ) == -1 ) {
        return;
    }

    int _userkey(0), _userid(0);
    js_map.ReadInteger( "userkey", _userkey );

    if ( _userkey!=0 )
    {
        UserSession * pSession = g_AgentServer->GetUserSession( _userkey );
        if ( pSession ) {
            _userid = pSession->GetUserid();
            User_Login_Query_Relogin( _userkey , _userid );
        }
        g_AgentServer->SendToClient( _userkey, (BYTE*) pMsg, wSize );
    }
}
开发者ID:hujb1983,项目名称:DouDiZhu,代码行数:25,代码来源:Handler_Onlines.cpp


示例20: ConnectServer

// 重连控制连接还是数据连接
void PasClient::ConnectServer( UserSession &user, bool tcp )
{
	// 更新最后一次登陆的时间
	user.Update( PCC_USER_LOGIN, tcp ) ;

	PccUser &pccuser = user.GetUser( tcp ) ;
	// 如果TCP连接
	if ( tcp ) {
		pccuser._fd = _tcp_handle.connect_nonb( pccuser._srv_ip.c_str(), pccuser._srv_port, 10 ) ;
		if ( pccuser._fd > 0 ) {
			pccuser.SetWaitResp() ;
		}
	} /**else { // 数据通道
		pccuser._fd = _udp_handle.connect_nonb( pccuser._srv_ip.c_str(), pccuser._srv_port, 10 ) ;
		if ( pccuser._fd == -1 )
			return ;
		pccuser.SetWaitResp() ;
	}*/

	PccUser &udpuser = user.GetUser( false ) ;
	udpuser.SetOffline() ;
	if(udpuser._fd != NULL) {
		CloseSocket(udpuser._fd);
		udpuser._fd = NULL;
	}

	// 通过TCP通道发送注册数据通道信息
	if ( ! tcp ) {
		PccUser &tcpuser = user.GetUser(true) ;

		char buf[1024] = {0};
		sprintf( buf, "SZ P %s|%s|%d\r\n", user.GetKey(true), _ip.c_str(), _port ) ;
		// 发送数据通道连接请求
		SendData( tcpuser._fd, buf, strlen(buf) ) ;

		//OUT_SEND( pccuser._srv_ip.c_str(), pccuser._srv_port, pccuser._username.c_str(), "fd %d, Tcp fd %d Send %s",
		//		pccuser._fd->_fd, tcpuser._fd->_fd, buf ) ;
	}
}
开发者ID:caocf,项目名称:workspace-kepler,代码行数:40,代码来源:pasclient.cpp



注:本文中的UserSession类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UserStringParameter类代码示例发布时间:2022-05-31
下一篇:
C++ UserServer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap