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


C++ StatusMessage::statusCode方法代码示例

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


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

示例1: availableMessages

void SessionClient::availableMessages()
{
  Message* message;
  while( ( message = receiveMessage() ) != NULL )
  {
    server_->checkSessionStateChange( this, message->type() );

    switch( message->type() )
    {
      case Message::MSG_HELLO:
      {
        // Send the client its initial nickname
        sendMessage( new NicknameMessage( nickName_ ) );
        break;
      }

      case Message::MSG_NICKNAME:
      {
        NicknameMessage* nickNameMessage = dynamic_cast<NicknameMessage*>( message );
        if( ! server_->clientChangedNickName( this, nickNameMessage ) )
        {
          // The nickname could not be changed, report the problem to the client
          sendMessage( new StatusMessage( Errors::Status_NickNameAlreadyRegistered ) );
        }
        else
        {
          // Change the nickname
          setNickName( nickNameMessage->nickName() );
          sendMessage( new NicknameMessage( nickName_ ) );
        }

        break;
      }

      case Message::MSG_STATUS:
      {
        StatusMessage* statusMessage = dynamic_cast<StatusMessage*>( message );
        Common::debug( "The client reports status code %d", statusMessage->statusCode() );

        Errors::StatusCode code = statusMessage->statusCode();
        switch( code )
        {
          case Errors::Status_Ok:
            Common::debug( "Session \"%s\" sent status OK", nickName_ );
            break;

          case Errors::Status_AcceptFileTransfer:
          case Errors::Status_RejectFileTransfer:
            if( ! server_->isFileTransferModeActive() )
            {
              sendMessage( new StatusMessage( Errors::Status_FileTransferCanceled ) );
              break;
            }

            // Save the status
            fileTransferStatus_ = code;

            server_->clientSentFileTransferResponse( this, code == Errors::Status_AcceptFileTransfer );
            break;

          default:
            Common::debug( "Session \"%s\" sent status %d", nickName_, code );
            break;
        }
        break;
      }

      case Message::MSG_CHAT:
      {
        ChatMessage* chatMessage = dynamic_cast<ChatMessage*>( message );
        if( ! server_->clientSentChatMessage( this, chatMessage ) )
        {
          sendMessage( new StatusMessage( Errors::Status_ChattingAlone ) );
        }
        break;
      }

      case Message::MSG_FILE_REQUEST:
      {
        // Deny new file transfers if one is already active
        if( server_->isFileTransferModeActive() )
        {
          sendMessage( new StatusMessage( Errors::Status_FileTransferCanceled ) );
          break;
        }

        FileTransferMessage* fileMessage = dynamic_cast<FileTransferMessage*>( message );
        if( ! server_->clientSentFileTransferRequest( this, fileMessage ) )
        {
          sendMessage( new StatusMessage( Errors::Status_ChattingAlone ) );
          break;
        }

        fileTransferStatus_ = Errors::Status_AcceptFileTransfer;
        break;
      }

      case Message::MSG_FILE_DATA:
      {
        FileDataMessage* dataMessage = dynamic_cast<FileDataMessage*>( message );
//.........这里部分代码省略.........
开发者ID:vpilo,项目名称:tari-exam,代码行数:101,代码来源:sessionclient.cpp


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