本文整理汇总了C++中MessagePtr::isCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePtr::isCommand方法的具体用法?C++ MessagePtr::isCommand怎么用?C++ MessagePtr::isCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePtr
的用法示例。
在下文中一共展示了MessagePtr::isCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleSessionMessage
/**
* @brief Handle messages in normal session mode
*
* This one is pretty simple. The message is validated to make sure
* the client is authorized to send it, etc. and it is added to the
* main message stream, from which it is distributed to all connected clients.
* @param msg the message received from the client
*/
void Client::handleSessionMessage(MessagePtr msg)
{
// Filter away blatantly unallowed messages
switch(msg->type()) {
using namespace protocol;
case MSG_LOGIN:
case MSG_USER_JOIN:
case MSG_USER_ATTR:
case MSG_USER_LEAVE:
case MSG_SESSION_CONFIG:
case MSG_STREAMPOS:
logger::notice() << this << "Got server-to-user only command" << msg->type();
return;
case MSG_DISCONNECT:
// we don't do anything with disconnect notifications from the client
return;
default: break;
}
if(msg->isOpCommand() && !isOperator()) {
logger::notice() << this << "Tried to use operator command" << msg->type();
return;
}
// Layer control locking
if(_session->isLayerControlLocked() && !isOperator()) {
switch(msg->type()) {
using namespace protocol;
case MSG_LAYER_CREATE:
case MSG_LAYER_ATTR:
case MSG_LAYER_ORDER:
case MSG_LAYER_RETITLE:
case MSG_LAYER_DELETE:
logger::debug() << this << "Non-operator use of layer control command";
return;
default: break;
}
}
// Locking (note. applies only to command stream)
if(msg->isCommand()) {
if(isDropLocked()) {
// ignore command
return;
} else if(isHoldLocked()) {
_holdqueue.append(msg);
return;
}
// Layer specific locking. Drop commands that affect layer contents
switch(msg->type()) {
using namespace protocol;
case MSG_PEN_MOVE:
if(isLayerLocked(_session->drawingContext(_id).currentLayer))
return;
break;
case MSG_LAYER_ATTR:
if(!isOperator() && isLayerLocked(msg.cast<LayerAttributes>().id()))
return;
break;
case MSG_LAYER_RETITLE:
if(!isOperator() && isLayerLocked(msg.cast<LayerRetitle>().id()))
return;
break;
case MSG_LAYER_DELETE: {
const LayerDelete &ld = msg.cast<LayerDelete>();
if(!isOperator() && isLayerLocked(ld.id()))
return;
// When merging, the layer below must be unlocked (and exist!)
if(ld.merge()) {
const LayerState *layer = _session->getLayerBelowId(ld.id());
if(!layer || isLayerLocked(layer->id))
return;
}
} break;
case MSG_PUTIMAGE:
if(isLayerLocked(msg.cast<PutImage>().layer()))
return;
break;
case MSG_FILLRECT:
if(isLayerLocked(msg.cast<FillRect>().layer()))
return;
break;
default: /* other types are always allowed */ break;
}
}
// Make sure the origin user ID is set
msg->setContextId(_id);
//.........这里部分代码省略.........
示例2: handleSessionMessage
/**
* @brief Handle messages in normal session mode
*
* This one is pretty simple. The message is validated to make sure
* the client is authorized to send it, etc. and it is added to the
* main message stream, from which it is distributed to all connected clients.
* @param msg the message received from the client
*/
void Client::handleSessionMessage(MessagePtr msg)
{
// Filter away blatantly unallowed messages
switch(msg->type()) {
using namespace protocol;
case MSG_LOGIN:
case MSG_USER_JOIN:
case MSG_USER_ATTR:
case MSG_USER_LEAVE:
case MSG_SESSION_CONFIG:
case MSG_STREAMPOS:
_server->printDebug(QString("Warning: user #%1 sent server-to-user only command %2").arg(_id).arg(msg->type()));
return;
default: break;
}
if(msg->isOpCommand() && !_isOperator) {
_server->printDebug(QString("Warning: normal user #%1 tried to use operator command %2").arg(_id).arg(msg->type()));
return;
}
// Layer control locking
if(_server->session().layerctrllocked && !_isOperator) {
switch(msg->type()) {
using namespace protocol;
case MSG_LAYER_CREATE:
case MSG_LAYER_ATTR:
case MSG_LAYER_ORDER:
case MSG_LAYER_RETITLE:
case MSG_LAYER_DELETE:
_server->printDebug(QString("Blocked layer control command from non-operator #%1").arg(_id));
return;
default: break;
}
}
// Locking (note. applies only to command stream)
if(msg->isCommand()) {
if(isDropLocked()) {
// ignore command
return;
} else if(isHoldLocked()) {
_holdqueue.append(msg);
return;
}
// Layer specific locking. Drop commands that affect layer contents
switch(msg->type()) {
using namespace protocol;
case MSG_PEN_MOVE:
if(isLayerLocked(_server->session().drawingctx[_id].currentLayer))
return;
break;
case MSG_LAYER_ATTR:
if(!_isOperator && isLayerLocked(msg.cast<LayerAttributes>().id()))
return;
break;
case MSG_LAYER_RETITLE:
if(!_isOperator && isLayerLocked(msg.cast<LayerRetitle>().id()))
return;
break;
case MSG_LAYER_DELETE:
if(!_isOperator && isLayerLocked(msg.cast<LayerDelete>().id()))
return;
break;
case MSG_PUTIMAGE:
if(isLayerLocked(msg.cast<PutImage>().layer()))
return;
break;
default: /* other types are always allowed */ break;
}
}
// Make sure the origin user ID is set
msg->setContextId(_id);
// Track state and special commands
switch(msg->type()) {
using namespace protocol;
case MSG_TOOLCHANGE:
_server->session().drawingContextToolChange(msg.cast<ToolChange>());
break;
case MSG_PEN_MOVE:
_server->session().drawingContextPenDown(msg.cast<PenMove>());
break;
case MSG_PEN_UP:
_server->session().drawingContextPenUp(msg.cast<PenUp>());
if(_barrierlock == BARRIER_WAIT) {
_barrierlock = BARRIER_LOCKED;
emit barrierLocked();
}
break;
//.........这里部分代码省略.........