// response to the client who has send a msg using sync mode. inline void NetMsgBusRspSendMsg(TcpSockSmartPtr sp_tcp, const std::string& netmsgbus_msgcontent, uint32_t sync_sid) { //LOG(g_log, core::lv_debug, "process a sync request begin :%lld, sid:%u, fd:%d\n", (int64_t)core::utility::GetTickCount(), sync_sid, sp_tcp->GetFD()); std::string msgid; if(CheckMsgId(netmsgbus_msgcontent, msgid)) { boost::shared_array<char> data; uint32_t data_len; if(GetMsgParam(netmsgbus_msgcontent, data, data_len)) { if(!SendMsg(msgid, data, data_len)) data_len = 0; // when finished process, write the data back to the client. uint32_t sync_sid_n = htonl(sync_sid); uint32_t data_len_n = htonl(data_len); uint32_t write_len = sizeof(sync_sid_n) + sizeof(data_len_n) + data_len; char* writedata = new char[write_len]; memcpy(writedata, &sync_sid_n, sizeof(sync_sid_n)); memcpy(writedata + sizeof(sync_sid_n), (char*)&data_len_n, sizeof(data_len_n)); memcpy(writedata + sizeof(sync_sid_n) + sizeof(data_len_n), data.get(), data_len); sp_tcp->SendData(writedata, write_len); //LOG(g_log, core::lv_debug, "process a sync request finished :%lld, sid:%u, fd:%d\n", (int64_t)core::utility::GetTickCount(), sync_sid, sp_tcp->GetFD()); } } }
inline void NetMsgBusToLocalMsgBus(const std::string& netmsgbus_msgcontent) { std::string msgid; if(CheckMsgId(netmsgbus_msgcontent, msgid)) { boost::shared_array<char> msgparam; uint32_t param_len; if(GetMsgParam(netmsgbus_msgcontent, msgparam, param_len)) { PostMsg(msgid, msgparam, param_len); } } }
const wchar_t* Language::GetMsg(LNGID nID) const { return CheckMsgId(nID)? m_Messages[nID].data() : L""; }