void PvaClientMonitor::start() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::start" << " channelName " << channelName << " connectState " << connectState << endl; } if(isStarted) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cerr << "PvaClientMonitor::start" << " channelName " << channelName << " why is this called twice " << endl; return; } if(connectState==connectIdle) connect(); if(connectState!=connected) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::start illegal state "; throw std::runtime_error(message); } isStarted = true; monitor->start(); }
bool PvaClientMonitor::waitEvent(double secondsToWait) { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::waitEvent" << " channelName " << channelName << endl; } if(!isStarted) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::waitEvent illegal state "; throw std::runtime_error(message); } if(poll()) return true; userWait = true; if(secondsToWait==0.0) { waitForEvent.wait(); } else { waitForEvent.wait(secondsToWait); } userWait = false; return poll(); }
bool PvaClientMonitor::poll() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::poll" << " channelName " << channelName << endl; } checkMonitorState(); if(!isStarted) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::poll illegal state "; throw std::runtime_error(message); } if(userPoll) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::poll did not release last"; throw std::runtime_error(message); } monitorElement = monitor->poll(); if(!monitorElement) return false; userPoll = true; pvaClientData->setData(monitorElement); return true; }
void PvaClientMonitor::releaseEvent() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::releaseEvent" << " channelName " << channelName << endl; } if(!isStarted) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::releaseEvent monitor not started "; throw std::runtime_error(message); } if(!userPoll) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::releaseEvent did not call poll"; throw std::runtime_error(message); } userPoll = false; monitor->release(monitorElement); }
void PvaClientRPC::request( PVStructure::shared_pointer const & pvArgument, PvaClientRPCRequesterPtr const & pvaClientRPCRequester) { checkRPCState(); this->pvaClientRPCRequester = pvaClientRPCRequester; if(responseTimeout<=0.0) { { Lock xx(mutex); if(rpcState!=rpcIdle) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = "channel " + channelName + " PvaClientRPC::request request aleady active "; throw std::runtime_error(message); } rpcState = rpcActive; } channelRPC->request(pvArgument); return; } request(pvArgument); }
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) const { qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); if (pMainForm) pMainForm->appendMessagesColor(channelName() + ' ' + s, c); }
Status PvaClientMonitor::waitConnect() { if(PvaClient::getDebug()) cout << "PvaClientMonitor::waitConnect\n"; if(connectState==connected) { if(!connectStatus.isOK()) connectState = connectIdle; return connectStatus; } if(connectState!=connectActive) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::waitConnect illegal connect state "; throw std::runtime_error(message); } if(PvaClient::getDebug()) { cout << "PvaClientMonitor::waitConnect calling waitForConnect.wait\n"; } waitForConnect.wait(); connectState = connectStatus.isOK() ? connected : connectIdle; if(PvaClient::getDebug()) { cout << "PvaClientMonitor::waitConnect" << " connectStatus " << (connectStatus.isOK() ? "connected" : "not connected"); } return connectStatus; }
void IrcChannelPrivate::init(const QString& title, IrcBufferModel* m) { IrcBufferPrivate::init(title, m); const QStringList chanTypes = m->network()->channelTypes(); prefix = getPrefix(title, chanTypes); name = channelName(title, chanTypes); }
void Server::doOnlineGroupMsg(shared_ptr<IMChat::MsgData> ptrMsg, const string& serializaStr) { m_mutex.lock(); //给所有服务器Publish消息,并存入数据库; string keyOnlineGroup("onlineGroup:"); keyOnlineGroup += ptrMsg->toid(); //vector 中数据序列为第一个userid第二个serverSocket....; vector<string> vecStr = m_redis.SortMultiSocket(keyOnlineGroup); //得到其他服务器Socket集合; //first->socket second-> userid unordered_map<string, string> dataUnorderMap; for (int i = 0; i < vecStr.size() / 2; i++) { if (vecStr[2 * i + 1] == m_strServerSocket) { if (ptrMsg->fromid() != vecStr[2 * i]) { //用户在当前服务器上; SessionPtr ptrConnection = m_tcpserver.getConnection_Manager().findUser(vecStr[2 * i]); if (NULL != ptrConnection) { m_codec.Send(ptrConnection, *ptrMsg); } } } else { dataUnorderMap[vecStr[2 * i + 1]] = vecStr[2 * i]; } } //对其他服务器Socket进行Publish操作; if (dataUnorderMap.size() >= 1) { for (size_t i = 0; i < dataUnorderMap.bucket_count(); ++i) { IMServer::serverGroupMsg publishData; bool bFlag = false; //socket -> userid for (auto local_it = dataUnorderMap.begin(i); local_it != dataUnorderMap.end(i); ++local_it) { publishData.add_userid()->assign(local_it->second); bFlag = true; } if (true == bFlag) { publishData.set_msgdata(serializaStr); //publish消息; string channelName("groupMsg:"); channelName += dataUnorderMap.begin(i)->first; m_redis.Publish(channelName, publishData.SerializeAsString()); } } } m_mutex.unlock(); }
PVStructure::shared_pointer PvaClientRPC::request(PVStructure::shared_pointer const & pvArgument) { checkRPCState(); { Lock xx(mutex); if(rpcState!=rpcIdle) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = "channel " + channelName + " PvaClientRPC::request request aleady active "; throw std::runtime_error(message); } rpcState = rpcActive; } channelRPC->request(pvArgument); if(responseTimeout>0.0) { waitForDone.wait(responseTimeout); } else { waitForDone.wait(); } Lock xx(mutex); if(rpcState!=rpcComplete) { Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = "channel " + channelName + " PvaClientRPC::request request timeout "; throw RPCRequestException(Status::STATUSTYPE_ERROR,message); } rpcState = rpcIdle; if(requestStatus.isOK()) return pvResponse; Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = "channel " + channelName + " PvaClientRPC::request status "; message += requestStatus.getMessage(); throw RPCRequestException(Status::STATUSTYPE_ERROR,message); }
PvaClientRPC::~PvaClientRPC() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout<< "PvaClientRPC::~PvaClientRPC" << " channelName " << channelName << endl; } }
void PvaClientMonitor::setRequester(PvaClientMonitorRequesterPtr const & pvaClientMonitorRequester) { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::setRequester" << " channelName " << channelName << endl; } this->pvaClientMonitorRequester = pvaClientMonitorRequester; }
void mmlf(const char *fmt, ...) { if(col == 0) s->printf("%c ", channelName(channel)); va_list ap; va_start(ap, fmt); int printed = s->vprintf(fmt, ap); va_end(ap); col += printed; if(col > 79) { col = 0; s->printf("\n"); } }
void PvaClientMonitor::monitorConnect( const Status& status, Monitor::shared_pointer const & monitor, StructureConstPtr const & structure) { Channel::shared_pointer chan(channel.lock()); if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::monitorConnect" << " channelName " << channelName << " status.isOK " << (status.isOK() ? "true" : "false") << endl; } connectStatus = status; connectState = connected; this->monitor = monitor; if(isStarted) { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::monitorConnect" << " channelName " << channelName << " is already started " << endl; } return; } if(status.isOK() && chan) { pvaClientData = PvaClientMonitorData::create(structure); pvaClientData->setMessagePrefix(chan->getChannelName()); } if(PvaClient::getDebug()) { cout << "PvaClientMonitor::monitorConnect calling waitForConnect.signal\n"; } waitForConnect.signal(); }
PvaClientMonitorDataPtr PvaClientMonitor::getData() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::getData" << " channelName " << channelName << endl; } checkMonitorState(); return pvaClientData; }
void PvaClientRPC::requestDone( const Status& status, ChannelRPC::shared_pointer const & channelRPC, PVStructure::shared_pointer const & pvResponse) { PvaClientRPCRequesterPtr req = pvaClientRPCRequester.lock(); { Lock xx(mutex); requestStatus = status; if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientRPC::requestDone" << " channelName " << channelName << endl; } if(rpcState!=rpcActive) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); string message = "channel " + channelName +" PvaClientRPC::requestDone" + " but not active"; throw std::runtime_error(message); } if(req && (responseTimeout<=0.0)) { rpcState = rpcIdle; } else { rpcState = rpcComplete; if(!req) this->pvResponse = pvResponse; waitForDone.signal(); } } if(req) { req->requestDone(status,shared_from_this(),pvResponse); } }
void PvaClientRPC::checkRPCState() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientRPC::checkRPCState" << " channelName " << channelName << " connectState " << connectState << endl; } if(connectState==connectIdle) connect(); }
void PvaClientMonitor::unlisten(MonitorPtr const & monitor) { if(PvaClient::getDebug()) cout << "PvaClientMonitor::unlisten\n"; PvaClientMonitorRequesterPtr req = pvaClientMonitorRequester.lock(); if(req) { req->unlisten(); return; } string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cerr << channelName + "pvaClientMonitor::unlisten called but no PvaClientMonitorRequester\n"; }
void PvaClientMonitor::monitorEvent(MonitorPtr const & monitor) { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::monitorEvent" << " channelName " << channelName << endl; } PvaClientMonitorRequesterPtr req = pvaClientMonitorRequester.lock(); if(req) req->event(shared_from_this()); if(userWait) waitForEvent.signal(); }
void PvaClientMonitor::stop() { if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientMonitor::stop" << " channelName " << channelName << endl; } if(!isStarted) return; isStarted = false; monitor->stop(); }
void PvaClientMonitor::connect() { if(PvaClient::getDebug()) cout << "PvaClientMonitor::connect\n"; issueConnect(); Status status = waitConnect(); if(status.isOK()) return; Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientMonitor::connect " + status.getMessage(); throw std::runtime_error(message); }
void PvaClientRPC::connect() { if(PvaClient::getDebug()) cout << "PvaClientRPC::connect\n"; issueConnect(); Status status = waitConnect(); if(status.isOK()) return; Channel::shared_pointer chan(channel.lock()); string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " PvaClientRPC::connect " + status.getMessage(); throw RPCRequestException(Status::STATUSTYPE_ERROR,message); }
PvaClientMonitor::~PvaClientMonitor() { if(PvaClient::getDebug()) cout<< "PvaClientMonitor::~PvaClientMonitor\n"; if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout<< "PvaClientMonitor::~PvaClientMonitor" << " channelName " << channelName << endl; } if(monitor) { if(isStarted) monitor->stop(); monitor->destroy(); } }
void PvaClientMonitor::issueConnect() { if(PvaClient::getDebug()) cout << "PvaClientMonitor::issueConnect\n"; Channel::shared_pointer chan(channel.lock()); if(connectState!=connectIdle) { string channelName("disconnected"); if(chan) channelName = chan->getChannelName(); string message = string("channel ") + channelName + " pvaClientMonitor already connected "; throw std::runtime_error(message); } if(chan) { connectState = connectActive; monitor = chan->createMonitor(monitorRequester,pvRequest); return; } throw std::runtime_error("PvaClientMonitor::issueConnect() but channel disconnected"); }
void PvaClientRPC::rpcConnect( const Status& status, ChannelRPC::shared_pointer const & channelRPC) { Channel::shared_pointer chan(channel.lock()); if(PvaClient::getDebug()) { string channelName("disconnected"); Channel::shared_pointer chan(channel.lock()); if(chan) channelName = chan->getChannelName(); cout << "PvaClientRPC::rpcConnect" << " channelName " << channelName << " status.isOK " << (status.isOK() ? "true" : "false") << endl; } if(!chan) return; connectStatus = status; connectState = connected; if(PvaClient::getDebug()) { cout << "PvaClientRPC::rpcConnect calling waitForConnect.signal\n"; } waitForConnect.signal(); }
QString MumbleClient::createChannel(QString channel_name) { QString name; if(channel_name == "") { int rand_len = 8; char rand[9]; genRandomStr(rand,rand_len); name = QString::fromLocal8Bit(rand); } else { name = channel_name; } _temp_channel_name = name; MumbleProto::ChannelState channel; channel.set_parent(0); channel.set_name(name.toStdString()); channel.set_temporary(true); int size = channel.ByteSize(); quint8 data[size]; channel.SerializeToArray(data,size); quint16 type = 7; this->sendMessage(data,type,size); emit channelName(_temp_channel_name); MumbleProto::UserState us; us.set_self_deaf(false); us.set_self_mute(false); us.set_session(_session_id); us.set_actor(_session_id); int msize = us.ByteSize(); quint8 mdata[msize]; us.SerializeToArray(mdata,msize); this->sendMessage(mdata,9,msize); return name; }
void qsamplerChannel::appendMessagesError( const QString& s ) const { qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); if (pMainForm) pMainForm->appendMessagesError(channelName() + "\n\n" + s); }
void Channel::appendMessagesClient( const QString& s ) const { MainForm *pMainForm = MainForm::getInstance(); if (pMainForm) pMainForm->appendMessagesClient(channelName() + ' ' + s); }
void qsamplerChannel::appendMessagesError( const QString& s ) const { if (m_pMainForm) m_pMainForm->appendMessagesError(channelName() + "\n\n" + s); }
void qsamplerChannel::appendMessagesClient( const QString& s ) const { if (m_pMainForm) m_pMainForm->appendMessagesClient(channelName() + ' ' + s); }