void Client::sendMessage(protocol::MessagePtr msg) { msg->setContextId(m_myId); // Command type messages go to the local fork too if(msg->isCommand()) emit drawingCommandLocal(msg); _server->sendMessage(msg); }
void CanvasModel::handleCommand(protocol::MessagePtr cmd) { using namespace protocol; // Apply ACL filter if(!m_aclfilter->filterMessage(*cmd)) { qDebug("Filtered message %d from %d", cmd->type(), cmd->contextId()); return; } if(cmd->isMeta()) { // Handle meta commands here switch(cmd->type()) { case MSG_CHAT: metaChat(cmd.cast<Chat>()); break; case MSG_USER_JOIN: metaUserJoin(cmd.cast<UserJoin>()); break; case MSG_USER_LEAVE: metaUserLeave(cmd.cast<UserLeave>()); break; case MSG_SESSION_OWNER: case MSG_USER_ACL: case MSG_SESSION_ACL: case MSG_LAYER_ACL: // Handled by the ACL filter break; case MSG_INTERVAL: /* intervals are used only when playing back recordings */ break; case MSG_LASERTRAIL: metaLaserTrail(cmd.cast<protocol::LaserTrail>()); break; case MSG_MOVEPOINTER: metaMovePointer(cmd.cast<MovePointer>()); break; case MSG_MARKER: metaMarkerMessage(cmd.cast<Marker>()); break; default: qWarning("Unhandled meta message type %d", cmd->type()); } } else if(cmd->isCommand()) { // The state tracker handles all drawing commands m_statetracker->receiveQueuedCommand(cmd); emit canvasModified(); } else { qWarning("CanvasModel::handleDrawingCommand: command %d is neither Meta nor Command type!", cmd->type()); } }