void logGeneric(const char *relpath, GenericOperation genop) { uint32_t msglen; uint8_t *buf; FileOperation fileop = FILE_OPERATION__INIT; // we are in panic mode, rsync will be required anyway if (logfd == -1) return; fileop.relative_path = (char *) relpath; fileop.op = &genop; packMessage(FileOperationType, &fileop, &buf, &msglen); // critical section writepending = 1; if (write(logfd, buf, msglen) != msglen) { errnoMsg(LOG_CRIT, "Could not write message."); // set dirty flag? } writepending = 0; if (switchpending == 1) handleSIGUSR1(0, NULL, NULL); }
void LLViewerInventoryItem::updateServer(BOOL is_new) const { // <edit> //if(gAgent.getID() != mPermissions.getOwner()) //{ // // *FIX: deal with this better. // llwarns << "LLViewerInventoryItem::updateServer() - for unowned item" // << llendl; if((mParentUUID == gLocalInventoryRoot) || (gInventory.isObjectDescendentOf(mUUID, gLocalInventoryRoot))) { // </edit> return; } if(!mIsComplete) { llwarns << "LLViewerInventoryItem::updateServer() - for incomplete item" << llendl; LLNotifications::instance().add("IncompleteInventoryItem"); return; } LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0); gInventory.accountForUpdate(up); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_UpdateInventoryItem); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_TransactionID, mTransactionID); msg->nextBlockFast(_PREHASH_InventoryData); msg->addU32Fast(_PREHASH_CallbackID, 0); packMessage(msg); gAgent.sendReliableMessage(); }
void LLViewerInventoryItem::updateServer(BOOL is_new) const { if(!mIsComplete) { // *FIX: deal with this better. // If we're crashing here then the UI is incorrectly enabled. llerrs << "LLViewerInventoryItem::updateServer() - for incomplete item" << llendl; return; } if(gAgent.getID() != mPermissions.getOwner()) { // *FIX: deal with this better. llwarns << "LLViewerInventoryItem::updateServer() - for unowned item" << llendl; return; } LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0); gInventory.accountForUpdate(up); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_UpdateInventoryItem); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_TransactionID, mTransactionID); msg->nextBlockFast(_PREHASH_InventoryData); msg->addU32Fast(_PREHASH_CallbackID, 0); packMessage(msg); gAgent.sendReliableMessage(); }
int push(const char *token, const char *payload) { char tokenBytes[32]; char message[293]; unsigned long msgLength; token2bytes(token, tokenBytes); msgLength = packMessage(message, 0, tokenBytes, payload); return SSL_write(ssl, message, (int)msgLength); }
void QV4DebugServiceImpl::messageReceived(const QByteArray &message) { QMutexLocker lock(&m_configMutex); QQmlDebugPacket ms(message); QByteArray header; ms >> header; TRACE_PROTOCOL(qDebug() << "received message with header" << header); if (header == "V8DEBUG") { QByteArray type; QByteArray payload; ms >> type >> payload; TRACE_PROTOCOL(qDebug() << "... type:" << type); if (type == V4_CONNECT) { QJsonObject parameters = QJsonDocument::fromJson(payload).object(); namesAsObjects = true; redundantRefs = true; if (parameters.contains("namesAsObjects")) namesAsObjects = parameters.value("namesAsObjects").toBool(); if (parameters.contains("redundantRefs")) redundantRefs = parameters.value("redundantRefs").toBool(); emit messageToClient(name(), packMessage(type)); stopWaiting(); } else if (type == V4_PAUSE) { debuggerAgent.pauseAll(); sendSomethingToSomebody(type); } else if (type == V4_BREAK_ON_SIGNAL) { QByteArray signal; bool enabled; ms >> signal >> enabled; //Normalize to lower case. QString signalName(QString::fromUtf8(signal).toLower()); if (enabled) breakOnSignals.append(signalName); else breakOnSignals.removeOne(signalName); } else if (type == "v8request") {
void LLViewerInventoryCategory::updateServer(BOOL is_new) const { // communicate that change with the server. if(LLAssetType::AT_NONE != mPreferredType) { LLNotifications::instance().add("CannotModifyProtectedCategories"); return; } LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0); gInventory.accountForUpdate(up); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_UpdateInventoryFolder); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_FolderData); packMessage(msg); gAgent.sendReliableMessage(); }
static void setShortMessage(MidiMessage* message, int status, int data1, int data2) { message->type = SHORT_MESSAGE; message->data.s.packedMsg = packMessage(status, data1, data2); }
void *SendHeartRun(void *arg) { pthread_detach(pthread_self()); char intervalOfSendPingREQ = 0; char intervalOfSendGetTime = 0; char intervalOfSendHeart = 0; char intervalKeepAlive = MQTT_KEEP_ALIVE / 10; _Bool needSendPublish = false; while(1) { debug_msg("5s"); sleep(5); if (deviceModel == AP) { debug_msg("current deviceModel is AP"); continue; } if (g_isCreated) { debug_msg("have created socket and connect to server\n"); // debug_msg("before wait semsendheart\n" ); // sem_wait(&g_semSendHeart); // debug_msg("after wait semsendheart\n "); if (g_isConnected) { /* connected to mqtt server */ debug_msg("g_isSubscribed = %d\n", g_isSubscribed); if (g_isSubscribed) { intervalOfSendPingREQ ++; intervalOfSendGetTime ++; intervalOfSendHeart ++; if (intervalOfSendPingREQ > intervalKeepAlive) { unsigned char pingREQ[2] = {0}; pingREQ[0] = 0xC0; pingREQ[1] = 0x00; sendSocket(pingREQ, 2, "mqtt pingreq"); intervalOfSendPingREQ = 0; } /* 120 * 5 = 600s = 1hour, so get current time from topicServer every 1 hour */ if (intervalOfSendGetTime > 120) { intervalOfSendGetTime = 0; /* TODO: get time form topicServer */ } if (intervalOfSendHeart > 12) { intervalOfSendHeart = 0; debug_msg("---"); sendSocket(mqttHeart, mqttHeartLen, "mqttHeart"); } } else { debug_msg("---"); // is not received suback from server. /* so should send mqtt subscribe */ struct mqttSend *mqtt = malloc(sizeof(struct mqttSend)); /* set message type */ mqtt->fixedHeader.messageType = SUBSCRIBE; /* set topic filter */ printf("g_mac len = %d\n", strlen(g_mac)); int count = LEN_OF_TOPICFILTER; int i = 0; mqtt->variableHeader.topicFilterArr = (char**)malloc(count * sizeof(char*)); /* set topic filter length */ mqtt->variableHeader.i_topicFilterArrCount = count; for (i = 0; i < count; i++) { unsigned char *topicFilter = malloc(strlen(g_subscribeTopicFilter[i]) + strlen(g_mac) + 1); bzero(topicFilter, strlen(g_subscribeTopicFilter[i]) + strlen(g_mac) + 1); memcpy(topicFilter, g_subscribeTopicFilter[i], strlen(g_subscribeTopicFilter[i])); memcpy(topicFilter + strlen(g_subscribeTopicFilter[i]), g_mac, strlen(g_mac)); printf("topicFilter len = %lu\n", strlen(topicFilter)); printf("topicFilter = %s\n", topicFilter); *(mqtt->variableHeader.topicFilterArr + i) = malloc(strlen(topicFilter) + 1); bzero(*(mqtt->variableHeader.topicFilterArr + i), strlen(topicFilter) + 1); memcpy(*(mqtt->variableHeader.topicFilterArr + i), topicFilter, strlen(topicFilter)); free(topicFilter); } unsigned char *temp = NULL; int len = packMessage(mqtt, &temp); for (i = 0; i < count; i++) { free(*(mqtt->variableHeader.topicFilterArr + i)); } free(mqtt->variableHeader.topicFilterArr); free(mqtt); printf("publishlen = %d\n", len); for (i = 0; i < len; i++) { printf("%02X,", temp[i]); } printf("\n" ); int ret = sendSocket(temp, len, "mqtt subscribe"); if (ret == -2) { // sem_post(&g_semSendHeart); /* for re-send this message */ } else { } free(temp); } } else { debug_msg("should send mqtt connect\n"); // is not received connack from server. /* so should send mqtt connect */ /* send connect message */ struct mqttSend * mqtt = malloc(sizeof(struct mqttSend)); mqtt->fixedHeader.messageType = CONNECT; mqtt->playLoad.clientID = malloc(LEN_OF_MAC); bzero(mqtt->playLoad.clientID, LEN_OF_MAC); memcpy(mqtt->playLoad.clientID, g_mac, LEN_OF_MAC - 1); unsigned char *temp = NULL; int len = packMessage(mqtt, &temp); free(mqtt->playLoad.clientID); free(mqtt); int i = 0; printf("len = %d\n", len); for (i = 0; i < len; i++) { printf("%02X,", temp[i]); } printf("\n" ); int ret = sendSocket(temp, len, "mqtt connect"); if (ret == -2) { // sem_post(&g_semSendHeart); /* to re-send this message */ } else { } free(temp); } } else { debug_msg("not create socket, should create it\n"); // should create socket, and connect to server. /* if is reConnect network, then continue */ if (g_isChecking) { debug_msg("--"); continue; } else { sem_post(&g_semConnectionCheck); } /* end g_isChecking else */ } /* end g_isCreated else */ } pthread_exit((void*)0); }