当前位置: 首页>>代码示例>>C++>>正文


C++ UserSession::sendSysChat方法代码示例

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


在下文中一共展示了UserSession::sendSysChat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doMailCmd

bool MailService::doMailCmd(const Cmd::t_NullCmd *cmd,const DWORD cmdLen)
{
  using namespace Cmd;
  using namespace Cmd::Session;
  switch (cmd->para)
  {
    case PARA_SCENE_SENDMAIL:
      {
        t_sendMail_SceneSession * rev = (t_sendMail_SceneSession *)cmd;

        UserSession * pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->mail.fromName);
        if (!pUser)
          pUser = UserSessionManager::getInstance()->getUserByID(rev->mail.fromID);

        /*//取消这个身份确认,避免一些物品丢失
        if (!pUser && rev->mail.type!=Cmd::Session::MAIL_TYPE_ACTIVITY)
        {
          Zebra::logger->error("[邮件]doMailCmd(PARA_SCENE_SENDMAIL): 发送邮件时未找到发送者 %s",rev->mail.fromName);
          return true;
        }
        */

        if (sendMail(* rev))
        {
          if (pUser) pUser->sendSysChat(Cmd::INFO_TYPE_GAME,"发送成功");
          Zebra::logger->info("[邮件]邮件发送成功 %s->%s(%u)",rev->mail.fromName,rev->mail.toName,rev->mail.toID);

          UserSession * toUser = UserSessionManager::getInstance()->getUserSessionByName(rev->mail.toName);
          if (!toUser) toUser = UserSessionManager::getInstance()->getUserByID(rev->mail.toID);
          if (toUser)
          {
            Cmd::stNotifyNewMail n;
            toUser->sendCmdToMe(&n,sizeof(n));
          }
        }
        return true;
      }
      break;
    case PARA_SCENE_GET_MAIL_LIST:
      {
        t_getMailList_SceneSession * rev = (t_getMailList_SceneSession *)cmd;
        UserSession * pUser = UserSessionManager::getInstance()->getUserByTempID(rev->tempID);
        if (!pUser)
        {
          Zebra::logger->error("[邮件]doMailCmd(PARA_SCENE_GET_MAIL_LIST): 取得邮件列表时未找到玩家");
          return true;
        }

        connHandleID handle = SessionService::dbConnPool->getHandle();
        if ((connHandleID)-1 == handle)
        {               
          pUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"取得邮件失败");
          Zebra::logger->error("[邮件]doMailCmd(PARA_SCENE_GET_MAIL_LIST): 得到数据库句柄失败");
          return true;
        }

        char where[128];

        //得到邮件列表
        bzero(where,sizeof(where));
        _snprintf(where,sizeof(where) - 1,"TOID=%u",pUser->id);

        mailHeadInfo *mailList;
        DWORD retcode = SessionService::dbConnPool->exeSelect(handle,"`MAIL`",mail_head_define,where,"DELTIME DESC",(BYTE **)&mailList);
        SessionService::dbConnPool->putHandle(handle);

        if (mailList)
        {
          for (DWORD i=0; i< retcode; i++)
          {
            if (mailList[i].state==MAIL_STATE_DEL)
              continue;

            stAddListMail al;
            al.id = mailList[i].id;
            al.state = mailList[i].state;
            if (MAIL_TYPE_AUCTION==mailList[i].type || MAIL_TYPE_SYS==mailList[i].type)
              al.type=1;//系统邮件
            strncpy(al.fromName,mailList[i].fromName,MAX_NAMESIZE);
            if (mailList[i].accessory && !mailList[i].itemGot)
              al.accessory = true;
            else
              al.accessory = false;
            zRTime ct;
            al.endTime = mailList[i].delTime>ct.sec()?mailList[i].delTime-ct.sec():0;

            pUser->sendCmdToMe(&al,sizeof(al));
          }
        }
        SAFE_DELETE_VEC(mailList);

        /*
        //得到邮件列表
        std::string escapeName;
        bzero(where,sizeof(where));
        _snprintf(where,sizeof(where) - 1,"TONAME='%s'",pUser->name);

        retcode = SessionService::dbConnPool->exeSelect(handle,"`MAIL`",mail_head_define,where,"DELTIME DESC",(BYTE **)&mailList);
        SessionService::dbConnPool->putHandle(handle);

//.........这里部分代码省略.........
开发者ID:edolphin-ydf,项目名称:hydzhengtu,代码行数:101,代码来源:MailService.cpp

示例2: addBadRelation

/**
* \brief 增加一个黑名单类型的关系
* \param name 上黑名单者
*/
void CRelationManager::addBadRelation(const char *name)
{
  CRelation *relation = NULL;
  relation = (CRelation *)getEntryByName(name);

  if (relation)
  {
    if (Cmd::RELATION_TYPE_BAD == relation->type)
    {
      user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方已经在黑名单列表中");
    }
    else
    {
      if (Cmd::RELATION_TYPE_LOVE == relation->type)
      {
        user->sendSysChat(Cmd::INFO_TYPE_FAIL,"必须先离婚才能将其加入黑名单!");
        return;
      }
      UserSession *otherUser = NULL;
      otherUser = UserSessionManager::getInstance()->getUserSessionByName(name);
      if (otherUser) 
      {
        otherUser->relationManager.removeRelation(user->name);
        otherUser->sendSysChat(Cmd::INFO_TYPE_BREAKFRIEND,"%s选择和你恩断义绝",user->name);
      }
      else
      {
        CRelation *relation = NULL;
        relation = (CRelation *)getEntryByName(name);
        if (relation) writeOfflineNotify(relation);
      }
      changeRelationType(name,Cmd::RELATION_TYPE_BAD);
    }
  }
  else
  {
    UserSession *otherUser = NULL;
    otherUser = UserSessionManager::getInstance()->getUserSessionByName(name);
    if (otherUser)
    {
      CRelation *relation = NULL;
      zRTime ctv;
      relation = new CRelation();
      if (relation)
      {
        relation->id = otherUser->id;
        relation->level = 0;
        strncpy(relation->name,otherUser->name,MAX_NAMESIZE);
        relation->type = Cmd::RELATION_TYPE_BAD;
        relation->lasttime = ctv.sec();
        relation->occupation = otherUser->occupation;
        //if (insertDBRecord(relation))
        //{
          //rwlock.wrlock();
          addEntry(relation);
          //rwlock.unlock();
          insertDBRecord(relation);

          sendStatusChange(relation,Cmd::RELATION_ADD);
          sendBlackListToGateway(name,Cmd::Session::BLACK_LIST_ADD);
        //}
        //else
        //{

        //  if (user) user->sendSysChat(Cmd::INFO_TYPE_GAME,"将 %s 加入黑名单失败",name);
        //  SAFE_DELETE(relation);
        //}
      }

      if (user) user->sendSysChat(Cmd::INFO_TYPE_GAME,"将 %s 加入了黑名单",name);
    }
    else
    {
      if (user) user->sendSysChat(Cmd::INFO_TYPE_FAIL,"人不在线无法确认");
    }
  }
}
开发者ID:adan830,项目名称:gameserver-2,代码行数:81,代码来源:RelationManager.cpp

示例3: msgParse_SuperService


//.........这里部分代码省略.........
		  }
		  break;
	      case PARA_RTN_ZONE_LIST:
		  {}
		  break;

	    default:
		break;
	  }
      }
      break;
    case Cmd::GmTool::CMD_GMTOOL:
      {
        using namespace Cmd::GmTool;
        switch(pNullCmd->para)
        {
          case PARA_CHAT_GMTOOL:
            {
              t_Chat_GmTool * rev = (t_Chat_GmTool *)pNullCmd;
              UserSession *pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->userName);
              if (!pUser) return true;

              SessionChannel::sendPrivate(pUser,rev->gmName,rev->content);
            }
            break;
          case PARA_MSG_REPLY_GMTOOL:
            {
              t_Msg_Reply_GmTool * rev = (t_Msg_Reply_GmTool *)pNullCmd;
              char buf[255];
              snprintf(buf,sizeof(buf),"GM对您的问题做出了回复:\n\t%s\n原件:\n\t%s",rev->reply,rev->content);
              //MailService::getMe().sendTextMail(rev->gmName,0,rev->userName,rev->userID,buf,(DWORD)-1,Cmd::Session::MAIL_TYPE_SYS);
              UserSession *pUser = UserSessionManager::getInstance()->getUserSessionByName(rev->userName);
              if (pUser)
                pUser->sendSysChat(Cmd::INFO_TYPE_GAME,"GM对您提出的问题做了回复,请及时查收邮件");
              return true;
            }
            break;
          case PARA_BROADCAST_GMTOOL:
            {
              t_Broadcast_GmTool * rev = (t_Broadcast_GmTool *)pNullCmd;
              Zebra::logger->debug("[GM工具]收到公告 %s:%s id=%u time=%u country=%u mapID=%u",rev->GM,rev->content,rev->id,rev->time,rev->country,rev->mapID);
              if (rev->id>5) return false;
              //置空取消公告
              if (0==strcmp(rev->content,""))
              {
                SessionService::wMsg.erase(rev->id);
                return true;
              }
              if (rev->time)
                if (rev->country)
                  if (rev->mapID)
                    {
                      SceneSession *scene = SceneSessionManager::getInstance()
                        ->getSceneByID((rev->country<<16)+rev->mapID);
                      if (scene)
                      {
                        Cmd::Session::t_broadcastScene_SceneSession send;
                        strncpy(send.info,rev->content,MAX_CHATINFO);
                        strncpy(send.GM,rev->GM,MAX_NAMESIZE);
                        send.mapID = scene->id;
                        scene->sendCmd(&send,sizeof(send));
#ifdef _DEBUG
                        Zebra::logger->debug("GM公告:%s mapID=%u mapName=%s",send.info,send.mapID,scene->name);
#endif
                      }
#ifdef _DEBUG
开发者ID:zhutaorun,项目名称:unitygame,代码行数:67,代码来源:SessionServer.cpp

示例4: processUserMessage

/**
* \brief 处理Gateway转发过来的客户端消息
* \param pNullCmd 消息体
* \param cmdLen 消息长度
* \return true 处理完毕,false 不在处理范围之中
*/
bool CRelationManager::processUserMessage(const Cmd::stNullUserCmd *pNullCmd,const DWORD cmdLen)
{
  switch(pNullCmd->byCmd)
  {
    case Cmd::RELATION_USERCMD:
      {
        switch(pNullCmd->byParam)
        {
          case UNMARRY_PARA:
            {
              CRelation* relation = NULL;
              relation = getMarryRelation();

              if (relation)
              {
                UserSession *otherUser = NULL;
                otherUser = UserSessionManager::getInstance()->getUserSessionByName(relation->name);
                if (otherUser) 
                {
                  removeRelation(relation->name);
                  otherUser->relationManager.removeRelation(user->name);
                  otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"%s选择和你离婚",user->name);
                  otherUser->updateConsort();
                }
                else
                {
                  CRelation *tRelation = NULL;

                  tRelation = (CRelation *)getEntryByName(relation->name);
                  if (tRelation) writeOfflineNotify(tRelation);
                  removeRelation(relation->name);
                }
                user->updateConsort();
              }
            }
            break;
          case Cmd::RELATION_STATUS_PARA:
            {
              Cmd::stRelationStatusCmd *rev = (Cmd::stRelationStatusCmd *)pNullCmd;
              switch(rev->byState)
              {
                case Cmd::RELATION_ADD:
                  {
                    if (!strncmp(rev->name,user->name,MAX_NAMESIZE))
                    {
                      user->sendSysChat(Cmd::INFO_TYPE_FAIL,"不能把自己加入名单中?");
                      return true;
                    }

                    if (300>size())
                    {
                      if (rev->type == Cmd::RELATION_TYPE_BAD)
                      {
                        addBadRelation(rev->name);
                      }
                      else
                      {
                        addEnemyRelation(rev->name);
                      }
                    }
                    else
                    {
                      user->sendSysChat(Cmd::INFO_TYPE_FAIL,"名单列表已满!");
                    }
                    return true;
                  }
                  break;
                case Cmd::RELATION_ANSWER_NO:
                  {
                    UserSession *otherUser = NULL;
                    otherUser = UserSessionManager::getInstance()->getUserByID(rev->userid);
                    if (otherUser)
                    {
                      switch(rev->type)
                      {
                        case Cmd::RELATION_TYPE_FRIEND:
                          {
                            otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不同意与你结为好友");
                            return true;
                          }
                          break;
                        case Cmd::RELATION_TYPE_LOVE:
                          {
                            otherUser->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不同意与你结为夫妻");
                          }
                          break;
                        default:
                          break;
                      }
                    }
                  }
                  break;
                case Cmd::RELATION_ANSWER_YES:
                  {
//.........这里部分代码省略.........
开发者ID:adan830,项目名称:gameserver-2,代码行数:101,代码来源:RelationManager.cpp


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