bool ONIKinectDevice::createColorStream() { Status rc; if (mDevice.getSensorInfo(SENSOR_COLOR) != NULL) { rc = mColorStream.create(mDevice, SENSOR_COLOR); if (rc != STATUS_OK) { std::ostringstream out; out << "Couldn't create color stream\n\n" << OpenNI::getExtendedError() << "\n"; onMessage(out.str()); return false; } } rc = mColorStream.start(); if (rc != STATUS_OK) { std::ostringstream out; out << "Couldn't start the color stream\n\n" << OpenNI::getExtendedError() << "\n"; onMessage(out.str()); return false; } newColorFrameListener = NewColorFrameListener(this); mColorStream.addNewFrameListener(&newColorFrameListener); return true; }
void IRC::handle_msg(const string& chan, const string& nick, const string& login, const string& host, const string& omsg) { string msg = omsg; if(chan.find_first_of("#&+!") == 0) { //Channel Message onMessage(chan, nick, login, host, msg); } else { //Private Messages if(msg.find("\x001") == 0 && msg.rfind("\x001") == msg.length() - 1) { //CTCP msg = msg.substr(1, msg.length() - 2); if(msg.compare("TIME") == 0) { onTime(nick,login,host,chan); } else if(msg.compare("VERSION") == 0) { onVersion(nick,login,host,chan); } else if(msg.substr(0, 4).compare("PING") == 0) { onPing(nick,login,host,chan,msg.substr(5)); } else if(msg.compare("FINGER") == 0) { onFinger(nick,login,host,chan); } else if(msg.substr(0, 6).compare("ACTION") == 0) { onAction(nick,login,host,chan,msg.substr(7)); } return; } onPrivateMessage(nick, login, host, msg); } }
void Messaging::resendUnacknowledged() { const auto now = timeProvider_(); std::vector<Message> expiredConfirmables; for (auto& unacknowledged : unacknowledged_) { auto& ua = unacknowledged.second; const auto factor = std::pow(2, ua.retransmits_ + 1) - 1; const auto nextTimeout = ua.sent_ + factor * ACK_TIMEOUT; if (nextTimeout <= now) { if (ua.retransmits_ < MAX_RETRANSMITS) { ++ua.retransmits_; ILOG << "Resending confirmable request with msgID=" << ua.msg_.messageId() << '\n'; sendMessage(ua.ip_, ua.port_, ua.msg_); } else { ILOG << "Confirmable request with msgID=" << ua.msg_.messageId() << " expired\n"; expiredConfirmables.emplace_back(Message(Type::Acknowledgement, ua.msg_.messageId(), Code::ServiceUnavailable, ua.msg_.token(), "")); } } } // Handling the expired confirmable requests for (auto& expiredConfirmable : expiredConfirmables) { onMessage(expiredConfirmable, 0, 0); } }
integer ServiceApp::postMessage(ConstStrA command, const Args & args, SeqFileOutput output) { if (instance->imOwner()) return onMessage(command,args,output); AutoArrayStream<char, StaticAlloc<65536> > buffer; if (args.length() > 127) return onCommandLineError(args); buffer.write((char)(args.length())); buffer.copy(command.getFwIter()); buffer.write(0); for(natural i = 0, cnt = args.length();i < cnt;i++){ buffer.copy(WideToUtf8Reader<ConstStrW::Iterator>(args[i].getFwIter())); buffer.write(0); } AutoArray<byte,SmallAlloc<4096> > replybuff; replybuff.resize(instance->getReplyMaxSize()); natural sz = instance->request(buffer.data(), buffer.length(), replybuff.data(), replybuff.length(), timeout); if (sz < sizeof(integer)) throw ErrorMessageException(THISLOCATION,String("Invalid reply")); else { integer res = *reinterpret_cast<integer *>(replybuff.data()); ConstStrA msg(reinterpret_cast<char *>(replybuff.data()+sizeof(integer)),sz - sizeof(integer)); output.copy(msg.getFwIter()); return res; } }
void ONIKinectDevice::onDeviceDisconnected(const DeviceInfo* pInfo) { onDisconnect(); std::ostringstream out; out << "Device \"" << pInfo->getUri() << "\" disconnected\n"; onMessage(out.str()); }
void Connection::onRead( const string &stuff ) { Message m; Json::Value json; Json::Reader reader; if (reader.parse(stuff, json)) { m.name = json["message"]["name"].asString(); m.type = json["message"]["type"].asString(); if (m.type == "string" && json["message"]["value"].isString()) { m.value = json["message"]["value"].asString(); } else if (m.type == "boolean") { if (json["message"]["value"].isInt()) { m.value = json["message"]["value"].asInt(); } else if (json["message"]["value"].isString()) { m.value = json["message"]["value"].asString(); } } else if (m.type == "range") { if (json["message"]["value"].isInt()) { m.value = json["message"]["value"].asInt(); } else if (json["message"]["value"].isString()) { m.value = json["message"]["value"].asString(); } } } onMessage(m); }
integer ServiceApp::onMessage(ConstStrA command, const Args & args, SeqFileOutput output) { if (command == ConstStrA(restartCmd) || command == ConstStrA(startForeCmd)) { return onMessage(startCmd,args,output); } if (command == ConstStrA(stopCmd)) { stop(); return 0; } if (command == ConstStrA(statusCmd)) { PrintTextA print(output); print("Service is running\n"); return 0; } if (command == ConstStrA(startCmd)) return 0; if (command == ConstStrA("restartDaemon")) { instance->restartDaemon(); } return integerNull; }
void ConnectionHandler::onPacketArrive(const base::packet::Header& header, base::packet::Packet& body, const SockAddr& clientaddr) { LOG(trace, "packet arrive: " << header << ", addr=" << addr()); rpc::Body msgbody; if (header.body_size()) { if (body.isFlat()) { iovec iov; body.getDirectPtr(&iov); if (!msgbody.ParseFromArray(iov.iov_base, iov.iov_len)) { LOG(error, "parse error!" << header << ", body=" << body); return; } } else { internal::PacketInputStream packetinput(body); ::google::protobuf::io::CodedInputStream in(&packetinput); if (!msgbody.ParseFromCodedStream(&in)) { LOG(error, "parse error!" << header << ", body=" << body); return; } } } onMessage(static_cast<rpc::OP>(header.op()), *msgbody.mutable_msgs(), clientaddr); }
//------------------------------------------------------------------------------------- void DebugHelper::script_msg(const std::string& s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); if(s.size() > 33 /* strlen("Traceback (most recent call last)" */) { if(s[0] == 'T' && s[10] == '(') { if(s.substr(0, 33) == "Traceback (most recent call last)") setScriptMsgType(log4cxx::ScriptLevel::SCRIPT_ERR); } } #ifdef NO_USE_LOG4CXX #else if(canLogFile_) LOG4CXX_LOG(g_logger, log4cxx::ScriptLevel::toLevel(scriptMsgType_), s); #endif onMessage(KBELOG_SCRIPT, s.c_str(), s.size()); #if KBE_PLATFORM == PLATFORM_WIN32 if(log4cxx::ScriptLevel::SCRIPT_ERR == scriptMsgType_) printf("[S_ERROR]: %s", s.c_str()); #endif }
void DebugHelper::critical_msg(const char * str, ...) { if(str == NULL) return; KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else va_list ap; va_start(ap, str); #if KBE_PLATFORM == PLATFORM_WIN32 uint32 size = _vsnprintf(_g_buf, DBG_PT_SIZE, str, ap); #else uint32 size = vsnprintf(_g_buf, DBG_PT_SIZE, str, ap); #endif va_end(ap); char buf[DBG_PT_SIZE]; kbe_snprintf(buf, DBG_PT_SIZE, "%s(%d) -> %s\n\t%s\n", _currFile.c_str(), _currLine, _currFuncName.c_str(), _g_buf); LOG4CXX_FATAL(g_logger, buf); #endif setFile("", "", 0); onMessage(LOG_CRITICAL, _g_buf, size); }
void CTaxasRoom::OnPlayerActTimeOut() { stMsgTaxasPlayerAct msg ; msg.cSysIdentifer = 0 ; msg.nValue = 0 ; msg.nRoomID = getRoomID() ; CTaxasPlayer* pPlayer = (CTaxasPlayer*)getPlayerByIdx(m_nCurWaitPlayerActionIdx); if ( pPlayer == nullptr ) { LOGFMTE("why cur wait player is null "); return ; } if ( m_nMostBetCoinThisRound == pPlayer->getBetCoinThisRound() ) { msg.nPlayerAct = eRoomPeerAction_Pass ; } else { msg.nPlayerAct = eRoomPeerAction_GiveUp ; } LOGFMTD("wait player act time out auto act room id = %d",getRoomID()) ; onMessage(&msg,ID_MSG_PORT_CLIENT,pPlayer->getSessionID()) ; pPlayer->increaseNoneActTimes(); }
void DebugHelper::backtrace_msg() { void ** traceBuffer = new void*[MAX_DEPTH]; uint32 depth = backtrace( traceBuffer, MAX_DEPTH ); char ** traceStringBuffer = backtrace_symbols( traceBuffer, depth ); for (uint32 i = 0; i < depth; i++) { // Format: <executable path>(<mangled-function-name>+<function // instruction offset>) [<eip>] std::string functionName; std::string traceString( traceStringBuffer[i] ); std::string::size_type begin = traceString.find( '(' ); bool gotFunctionName = (begin >= 0); if (gotFunctionName) { // Skip the round bracket start. ++begin; std::string::size_type bracketEnd = traceString.find( ')', begin ); std::string::size_type end = traceString.rfind( '+', bracketEnd ); std::string mangled( traceString.substr( begin, end - begin ) ); int status = 0; size_t demangledBufferLength = 0; char * demangledBuffer = abi::__cxa_demangle( mangled.c_str(), 0, &demangledBufferLength, &status ); if (demangledBuffer) { functionName.assign( demangledBuffer, demangledBufferLength ); // __cxa_demangle allocates the memory for the demangled // output using malloc(), we need to free it. free( demangledBuffer ); } else { // Didn't demangle, but we did get a function name, use that. functionName = mangled; } } std::string ss = (boost::format("Stack: #%1% %2%\n") % i % ((gotFunctionName) ? functionName.c_str() : traceString.c_str())).str(); #ifdef NO_USE_LOG4CXX #else LOG4CXX_INFO(g_logger, ss); #endif onMessage(KBELOG_PRINT, ss.c_str(), ss.size()); } free(traceStringBuffer); delete[] traceBuffer; }
void JoinGameDelegate::onNewContentControl(Control *, Control *newGui) { if(!newGui) return; if(newGui->getTag() != IDGUI_JOIN_GAME) return; curGui = newGui; SimGui::Canvas *root; if (curGui) root = curGui->getCanvas(); else return; if(!root) return; //set the help control SimGui::HelpCtrl *hc = root->getHelpCtrl(); if (! hc) { FearGui::FGHelpCtrl *helpCtrl = new FearGui::FGHelpCtrl(); root->setHelpCtrl(helpCtrl); } //add a var so we can keep an eye on the filter CMDConsole* console = CMDConsole::getLocked(); mCurFilter = atoi(console->getVariable(curFilterVariable)); //disable the join button until a game has been selected verifyServer(); //check for a new master MOTD verifyMasterMOTD(); //hide the filter combo if the connection is a LAN FearGui::FGComboBox *combo = dynamic_cast<FearGui::FGComboBox*>(curGui->findControlWithTag(IDCTG_FILTER_LIST)); if (! stricmp(Console->getVariable("Pref::JoinGameMode"), "LAN")) { if (combo) combo->setVisible(FALSE); } else if (combo) combo->setVisible(TRUE); //create the var if (! stricmp(Console->getVariable("pref::AutoRefresh"), "")) { Console->setVariable("pref::AutoRefresh", "TRUE"); } //see if we should do an auto refresh if (! stricmp(Console->getVariable("pref::AutoRefresh"), "FALSE")) { gbAutoRefreshDone = TRUE; } else if (! gbAutoRefreshDone) { onMessage(this, IDCTG_SERVER_REFRESH_LIST); gbAutoRefreshDone = TRUE; } }
void BaseActor::onCollide(BaseActor* actor) { if (isCollide(actor)) { onMessage("onCollide", (void*)actor); actor->onMessage("onCollide", (void*)this); } eachChildren([&] (BaseActor& child) { child.collide(actor); }); }
void Service::processAllMessage() { boost::mutex::scoped_lock lock(_muMsg); while (!_messageQueue.empty()) { onMessage(_messageQueue.front()); _messageQueue.pop(); } }
bool CTaxasRoom::onMessage( stMsg* prealMsg , eMsgPort eSenderPort , uint32_t nPlayerSessionID ) { if ( ISitableRoom::onMessage(prealMsg,eSenderPort,nPlayerSessionID) ) { return true ; } switch (prealMsg->usMsgType ) { //case MSG_TP_REQUEST_ROOM_INFO: // { // LOGFMTI("send room info to player session id = %d",nPlayerSessionID ); // sendRoomInfoToPlayer(nPlayerSessionID); // } // break; //case MSG_REQUEST_ROOM_DETAIL: // { // stMsgRequestRoomDetailRet msgRet ; // msgRet.detailInfo.nCreatOwnerUID = getOwnerUID(); // msgRet.detailInfo.nCurrentCount = GetPlayerCntWithState(eRoomPeer_SitDown); // msgRet.detailInfo.nRoomID = GetRoomID(); // msgRet.detailInfo.nSmiallBlind = getLittleBlind(); // msgRet.detailInfo.nSeatCnt = getSeatCnt(); // sprintf_s(msgRet.detailInfo.vRoomName,sizeof(msgRet.detailInfo.vRoomName),"%s",getRoomName()); // SendMsgToPlayer(nPlayerSessionID,&msgRet,sizeof(msgRet)) ; // } // break; //case MSG_REQUEST_MY_OWN_ROOM_DETAIL: // { // stMsgRequestMyOwnRoomDetailRet msgRet ; // msgRet.nRet = 0 ; // msgRet.nRoomType = eRoom_TexasPoker ; // msgRet.nCanWithdrawProfit = m_nRoomProfit ; // msgRet.nConfigID = m_stRoomConfig.nConfigID ; // msgRet.nDeadTime = m_nDeadTime ; // msgRet.nFollows = 2 ; // msgRet.nRoomID = GetRoomID() ; // msgRet.nTotalProfit = m_nTotalProfit ; // sprintf_s(msgRet.vRoomName,sizeof(msgRet.vRoomName),"%s",getRoomName()); // SendMsgToPlayer(nPlayerSessionID,&msgRet,sizeof(msgRet)) ; // } // break; case MSG_TP_CHANGE_ROOM: { LOGFMTE("change room function canncel"); return true ; stMsgTaxasPlayerLeave leave ; onMessage(&leave,ID_MSG_PORT_CLIENT,nPlayerSessionID); return true ; } break; default: return false ; } return true ; }
DeviceStatus ONIKinectDevice::initialize(void) { Status rc = OpenNI::initialize(); if (rc != STATUS_OK) { std::ostringstream out; out << "Initialize failed\n" << OpenNI::getExtendedError() << "\n"; onMessage(out.str()); return DEVICESTATUS_ERROR; }else{ onMessage("OpenNI device initialized\n"); OpenNI::addDeviceConnectedListener(this); OpenNI::addDeviceDisconnectedListener(this); OpenNI::addDeviceStateChangedListener(this); return DEVICESTATUS_OK; } }
void Channel::onReceiveData(void * pData, int iLength) { Json::Value rpc; while (m_JsonBuffer.getJsonFromBuffer((char*)pData, iLength, rpc)) { onMessage(rpc); pData = 0; iLength = 0; } }
void Host::handleReceiveEvent(ENetEvent* event) { ENetPacket* packet = event->packet; PeerPtr peer = (Peer*) event->peer->data; MessagePtr message = MessageCreate(0); message->setPacket(packet); onMessage(peer, message); }
void Connection::onRead( const boost::system::error_code& err, size_t bytes ) { std::cout << "On read..." << bytes << std::endl; if ( err ) { std::cout << err.message() << " in onRead" << std::endl; stop(); return; } std::string msg( _bigReadBuffer, bytes ); //std::cout << "From " << _login << " client: " << msg << std::endl; Stanza st; try { st.load( msg ); } catch ( ... ) { std::cout << "Corrupted XML stanza" << std::endl; stop(); return; } // if ( ( _loggedIn == false ) && ( st.getStanzaType() != Stanza::IQ || // ( st.getSubType() != Stanza::SIGNIN && st.getSubType() != Stanza::SIGNUP ) ) ) // { // stop(); // return; // } switch ( st.getStanzaType() ) { case Stanza::MESSAGE: onMessage( st ); break; case Stanza::PRESENCE: onPresence(); break; case Stanza::IQ: onRequest( st ); break; case Stanza::ROASTER: onRoaster(); break; default: break; } }
void handleEvents() { MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); onMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam); } }
void CGoldenBetState::onStateDuringTimeUp() { // time out stMsgGoldenPlayerAct act ; act.nPlayerAct = (uint8_t)eRoomPeerAction_GiveUp ; act.nValue = 0 ; auto pp = m_pRoom->getPlayerByIdx(m_pRoom->getCurActIdx()) ; assert(pp && "why current act player is null ?" ); LOGFMTD("player not act so give up idx = %u",m_pRoom->getCurActIdx()) ; onMessage(&act,ID_MSG_PORT_CLIENT,pp->getSessionID()); }
//------------------------------------------------------------------------------------- void DebugHelper::print_msg(std::string s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else LOG4CXX_INFO(g_logger, s); #endif onMessage(KBELOG_PRINT, s.c_str(), s.size()); }
//------------------------------------------------------------------------------------- void DebugHelper::warning_msg(std::string s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else LOG4CXX_WARN(g_logger, s); #endif onMessage(KBELOG_WARNING, s.c_str(), s.size()); }
//------------------------------------------------------------------------------------- void DebugHelper::debug_msg(const std::string& s) { KBEngine::thread::ThreadGuard tg(&this->logMutex); #ifdef NO_USE_LOG4CXX #else if(canLogFile_) LOG4CXX_DEBUG(g_logger, s); #endif onMessage(KBELOG_DEBUG, s.c_str(), s.size()); }
void FGIRCNicknames::onMouseDown(const Event &event) { Parent::onMouseDown(event); if (event.mouseDownCount > 1) { if (selectedCell.y == prevSelected.y) { onMessage(this, IDIRC_MENUOPT_PRIVATE_CHAT); } } prevSelected = selectedCell; }
BOOL PBModule::ProcessMessage (int appid, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PPBINSTSTRUCT pInstStruct; // Notify specified instance for (pInstStruct = m_pInstHead; pInstStruct; pInstStruct = pInstStruct->pNext) { if (pInstStruct->instID == appid) return onMessage (hwnd, msg, wparam, lparam, pInstStruct->pWrappedObj); } return FALSE; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), grid(nullptr), model(nullptr) { ui->setupUi(this); CenterFloatLayout* layout = new CenterFloatLayout(ui->frame); layout->setContentsMargins(8,8,8,8); layout->addWidget(ui->tableView); //ui->frame->setLayout(layout); // connect the open menu item connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile()) ); connect( Logger::instance(), SIGNAL(onMessage(QString)), this, SLOT(printLog(QString)) ); }
void SipHandler::hookUpPlugin( SipPlugin* sip ) { QObject::connect( sip, SIGNAL( peerOnline( QString ) ), SLOT( onPeerOnline( QString ) ) ); QObject::connect( sip, SIGNAL( peerOffline( QString ) ), SLOT( onPeerOffline( QString ) ) ); QObject::connect( sip, SIGNAL( msgReceived( QString, QString ) ), SLOT( onMessage( QString, QString ) ) ); QObject::connect( sip, SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfo( QString, SipInfo ) ) ); QObject::connect( sip, SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersion( QString, QString ) ) ); QObject::connect( sip, SIGNAL( avatarReceived( QString, QPixmap ) ), SLOT( onAvatarReceived( QString, QPixmap ) ) ); QObject::connect( sip, SIGNAL( avatarReceived( QPixmap ) ), SLOT( onAvatarReceived( QPixmap ) ) ); QObject::connect( sip->account(), SIGNAL( configurationChanged() ), sip, SLOT( configurationChanged() ) ); }
void TDBProcess::run() { Service::printConsole("[%04d] DBGW Process running OK\n",m_iThreadNo); //m_thread.start(this,&TDBProcess::ReconnectProcess); UserTransferMessage utm; while( !m_bStop ) { g_dagwlog.print("[%04d] try to get msg\n", m_iThreadNo ); m_queue.get(utm); g_dagwlog.print("[%04d] get msg ok\n", m_iThreadNo ); onMessage( utm.getReq(), utm); } Service::printConsole("[%04d] DBGW Process quit\n",m_iThreadNo); }