2019-08-27 websocket

// 发送WebSocket通知 templatebool TWebsocket(const T& struNotify, const std::string& strSecurity = "") { auto pNotifyData = std::make_shared(struNotify); if (nullptr == pNotifyData) { IVMS_LOG_ERROR("Websocket Input Data Error."); return false; } protocol::WebSocketNotifyData struWebsocketdata(pNotifyData); struWebsocketdata.strGuid = Base::GuidUtil::CreateGuid(); struWebsocketdata.strType = pNotifyData->TypeName(); MessageNotify struNotifyData; struNotifyData.dst_id = lpcclient::kMainCompnentID; struNotifyData.customize[protocol::kProtocol] = protocol::kWebSocket; if (!strSecurity.empty()) { struNotifyData.customize[protocol::kSecurity] = strSecurity; } struNotifyData.lpc_body = struWebsocketdata.JSONStr(); if (!lpcNotify(struNotifyData)) { IVMS_LOG_ERROR("Websocket Notify Failed.Type[%s]", struWebsocketdata.strType.c_str()); return false; } IVMS_LOG_INFO("Websocket Notify Success.Type[%s]", struWebsocketdata.strType.c_str()); return true; }

你可能感兴趣的:(2019-08-27 websocket)