void MainWindow::initializeControl() { optionDlg = NULL; aboutDlg = NULL; move(0, 0); resize(640, 480); setCentralWidget(ui->plainTextEdit); myLog = new MyLog; bool res = connect(&myLog->sync, SIGNAL(onMessage(QString)), this, SLOT(_onMessage(QString))); if (!res) { LOG_ERROR("connect return false"); } }
void WebSocketPort::receivedThreads(websocketpp::connection_hdl client, std::string data) { try { int ID = this->connectionList.at(client); if (_onMessage == NULL) { return; } _onMessage(ID, data); for (unsigned int i = 0; i < this->threadsList.size(); i++) { if (this_thread::get_id() == this->threadsList[i]->get_id()) {//fixme:free memory of thread? this->threadsList.erase(this->threadsList.begin() + i); } } } catch (exceptionEx &ex) { lNote("WSR.Error.OnReceive: " + std::string(ex.what())); } catch (exception &ex) { lNote("WSR.Error.OnReceive: " + std::string(ex.what())); } catch (...) { lNote("WSR.Error.OnReceive: UNKNOWN"); } }
// realData已经不包含前4个数据 void RpcClient::socketClientMessage(SocketClient* client, const void* realData, size_t size) { auto key = _getSocketWithClient(client); if (!rpc::message_is_complete((char *)realData, size)) { if (_onStatus) { _onStatus(_ctx, StatusCheckCRCError, "check crc error", key); } return; } libra_slice cmd_range; libra_slice data_range; rpc::message_unpack((char*)realData, size, &cmd_range, &data_range); if (_onMessage) { std::string cmd(cmd_range.begin, cmd_range.end - cmd_range.begin); _onMessage(_ctx, cmd.c_str(), data_range.begin, data_range.end - data_range.begin, key); } }