本文整理汇总了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 );
//.........这里部分代码省略.........