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


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

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


在下文中一共展示了UserSession::sendCmdToMe方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: sendPrivateChatToFriend

/**
* \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: 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

示例4: 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

示例5: 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

示例6: sendCmdToMyFriendExcept

/**
* \brief 发送消息给自己的所有简单社会关系
* \param pCmd 消息
* \param cmdLen 消息长度
* \param sendMe 是否发给自己
*/
void CRelationManager::sendCmdToMyFriendExcept(const void *pCmd,const DWORD cmdLen,bool sendMe,const char * except)
{
  //rwlock.rdlock();
  if (sendMe)
    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 && strncmp(pUser->name,except,MAX_NAMESIZE))
        {
          pUser->sendCmdToMe(pCmd,cmdLen);
        }
      }
    }
  }
  //rwlock.unlock();
}
开发者ID:adan830,项目名称:gameserver-2,代码行数:29,代码来源:RelationManager.cpp

示例7: turnBackMail

/* \brief 退回一封邮件
 *  \param mailID 邮件ID
 *
 */
bool MailService::turnBackMail(DWORD mailID)
{
  using namespace Cmd::Session;

  connHandleID handle = SessionService::dbConnPool->getHandle();
  if ((connHandleID)-1 == handle)
  {               
    Zebra::logger->error("[邮件]turnBackMail: 得到数据库句柄失败");
    return false;
  }

  char where[128];
  bzero(where,sizeof(where));
  _snprintf(where,sizeof(where) - 1,"ID=%u",mailID);

  mailTurnBackInfo mail;
  DWORD retcode = SessionService::dbConnPool->exeSelectLimit(handle,"`MAIL`",mail_turnback_define,where,NULL,1,(BYTE*)&mail);
  if (1 != retcode
      || mail.state==MAIL_STATE_DEL
      || mail.type!=MAIL_TYPE_MAIL
      || mail.accessory!=1
      || mail.itemGot!=0
      || (0==mail.fromID && 0==strncmp("",mail.fromName,MAX_NAMESIZE)))
      //|| 0==strncmp("",mail.fromName,MAX_NAMESIZE)
      //|| 0==mail.fromID)
  {
    Zebra::logger->error("[邮件]不能退还邮件 mailID=%u retCode=%d",mailID,retcode);
    SessionService::dbConnPool->putHandle(handle);
    return false;
  }

  char temp[MAX_NAMESIZE];
  mail.state = MAIL_STATE_NEW;
  strncpy(temp,mail.fromName,MAX_NAMESIZE);
  strncpy(mail.fromName,mail.toName,MAX_NAMESIZE);
  strncpy(mail.toName,temp,MAX_NAMESIZE);
  strncpy(mail.title,"退回的物品",MAX_NAMESIZE);
  mail.type = MAIL_TYPE_RETURN;
  zRTime ct;
  mail.createTime = ct.sec();
  mail.delTime = mail.createTime + 60*60*24*7;
  _snprintf(mail.text,255-1,"%s 谢绝了你发送的物品",mail.fromName);
  mail.recvMoney = 0;
  mail.recvGold = 0;
  DWORD t = mail.fromID;
  mail.fromID = mail.toID;
  mail.toID = t;

  retcode = SessionService::dbConnPool->exeUpdate(handle,"`MAIL`",mail_turnback_define,(BYTE*)&mail,where);
  SessionService::dbConnPool->putHandle(handle);
  if (1 != retcode)
  {
    Zebra::logger->error("[邮件]返还邮件Update失败:mailID=%u,retcode=%d",mailID,retcode);
    return false;
  }

  UserSession * toUser = UserSessionManager::getInstance()->getUserSessionByName(mail.toName);
  if (toUser)
  {
    Cmd::stNotifyNewMail n;
    toUser->sendCmdToMe(&n,sizeof(n));
  }
  return true;
}
开发者ID:edolphin-ydf,项目名称:hydzhengtu,代码行数:68,代码来源:MailService.cpp

示例8: 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

示例9: processUserMessage


//.........这里部分代码省略.........
                  break;
                case Cmd::RELATION_QUESTION:
                     //free 禁止好友功能
//                     user->sendSysChat(Cmd::INFO_TYPE_FAIL, "好友系统正在开 发中!");
//                                     break;
//#if 0                     
					{
                    if (!strncmp(rev->name,user->name,MAX_NAMESIZE))
                    {
                      user->sendSysChat(Cmd::INFO_TYPE_FAIL,"你在开玩笑吗?加自己为好友!");
                      return true;
                    }
                    CRelation *relation = NULL;
                    relation = (CRelation *)getEntryByName(rev->name);
                    if (relation)
                    {
                      if (!strncmp(rev->name,relation->name,MAX_NAMESIZE) && Cmd::RELATION_TYPE_BAD != relation->type)
                      {
                        user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方已经在你的好友列表中了,无需再添加!");
                        return true;
                      }
                    }

                    UserSession *otherUser = NULL;
                    otherUser = UserSessionManager::getInstance()->getUserSessionByName(rev->name);
                    if (otherUser)
                    {
                      if (isset_state(otherUser->sysSetting,Cmd::USER_SETTING_FRIEND))
                      {

                        user->sendSysChat(Cmd::INFO_TYPE_GAME,"好友请求已发送,等待对方应答!");
                        rev->userid = user->id;
                        strncpy(rev->name,user->name,MAX_NAMESIZE);
                        otherUser->sendCmdToMe(rev,sizeof(Cmd::stRelationStatusCmd));
                      }
                      else
                        user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方添加好友未开启");
                    }
                    else
                    {
                      user->sendSysChat(Cmd::INFO_TYPE_FAIL,"对方不在线不能响应你的邀请");
                    }
//#endif 
                  break;
					}
                case Cmd::RELATION_REMOVE:
                  {
                    CRelation *rel = NULL;
                    rel = (CRelation *)getEntryByName(rev->name);
                    if (!rel) return true;
                    int type = rel->type;
                
                    if (Cmd::RELATION_TYPE_BAD == type || Cmd::RELATION_TYPE_ENEMY == type)
                    {
                      removeRelation(rev->name); // 删除黑名单成员
                    }
                    else
                    {
                      if (Cmd::RELATION_TYPE_LOVE == type)
                      {
                        user->sendSysChat(Cmd::INFO_TYPE_FAIL,"你必须到民政官那里去办理离婚手续!");
                        return true;
                      }
                      UserSession *otherUser = NULL;
                      otherUser = UserSessionManager::getInstance()->getUserSessionByName(rev->name);
                      if (otherUser) 
开发者ID:adan830,项目名称:gameserver-2,代码行数:67,代码来源:RelationManager.cpp


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