本文整理汇总了C++中Msg::setHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::setHeader方法的具体用法?C++ Msg::setHeader怎么用?C++ Msg::setHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg::setHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextMsg
Msg *
MsgList::alloc(DxMessageCode code_, int32_t activityId_, void *data_,
int32_t len_, MemBlk *blk_, MsgDataType dataType_)
{
Msg *msg;
SseInterfaceHeader hdr;
lock();
if (msgList.empty()) {
Debug(DEBUG_MSGLIST, allocs, "allocs");
Debug(DEBUG_MSGLIST, frees, "frees");
unlock();
Fatal(ERR_NMA);
}
msg = msgList.front();
msgList.pop_front();
Assert(!msg->allocated());
msg->setAllocated();
hdr.code = code_;
hdr.activityId = activityId_;
GetNssDate(hdr.timestamp);
hdr.messageNumber = GetNextMsg();
msg->setHeader(hdr);
msg->setData(data_, len_, blk_, dataType_);
++allocs;
unlock();
return (msg);
}
示例2: passThruCfg
//.........这里部分代码省略.........
** might be a long time)... An integer version number
** has been added to the top of the file.
**
** Thus, if the first entry is 40003 this code looks
** for the original 13 fixed entries and uses a
** resolution of 1HZ. If the first entry is a
** version number than the version number is checked
** as needed and new entries can be read from the file.
*/
/*
** Remove ALL the version code. Configuration
** file is now parameterized.
*/
int cmd = pt->getNxtCmd();
while (cmd)
{
timer.sleep(3000);
if (++counter == 10)
Fatal(ERR_IPIV); // Something is wrong!
hdr.activityId = pt->getActivityId();
hdr.code = cmd;
LogInfo(0, -1, "Reading standalone Config File cmd %d actId %d",
hdr.code, hdr.activityId);
hdr.messageNumber = lastMsg++;
switch (hdr.code) {
case CONFIGURE_DX:
{
hdr.dataLength = sizeof(DxConfiguration);
msg = msgList->alloc();
msg->setHeader(hdr);
/* Allocate space for the cmd specific data */
blk = partitionSet->alloc((size_t) hdr.dataLength);
Assert(blk);
if (!blk)
Fatal(ERR_MAF);
data = blk->getData();
/* Initialize data.... */
DxConfiguration *config = (DxConfiguration *)data;
config->a2dClockrate = 104.16;
msg->setData(data, hdr.dataLength, blk);
break;
}
case SEND_DX_ACTIVITY_PARAMETERS:
{
hdr.dataLength = sizeof(DxActivityParameters);
msg = msgList->alloc();
msg->setHeader(hdr);
/* Allocate space for the cmd specific data */
blk = partitionSet->alloc((size_t) hdr.dataLength);
Assert(blk);
if (!blk)
Fatal(ERR_MAF);
data = blk->getData();
/* Initialize data.... */
DxActivityParameters *params = (DxActivityParameters *)data;
示例3: extractArgs
//
// routine: receive and send on incoming messages
//
// Notes:
// No analysis of the message is performed - that is left
// to the command processor task. Instead, the local copy
// of the header
// is demarshalled to determined whether or not there
// is associated data; if there is, space is allocated to
// contain it.
void *
SseInputTask::routine()
{
extractArgs();
Timer timer;
if (cmdArgs->noSSE()) {
processIpFromFile();
while (1)
timer.sleep(3000);
};
// run forever, waiting for messages from the SSE
bool stopIssued = false;
bool done = false;
uint32_t lastCode = MESSAGE_CODE_UNINIT;
int32_t lastLen = 0;
uint32_t lastTime = 0;
while (!done) {
// if there's no connection, request that it be
// established, then wait for that to happen
if (!sse->isConnected()) {
requestConnection();
while (!sse->isConnected())
timer.sleep(3000);
}
stopIssued = false;
// got a connection - wait for data to come in
SseInterfaceHeader hdr;
Error err = sse->recv((void *) &hdr, sizeof(hdr));
if (err) {
switch (err) {
case EAGAIN:
case EINTR:
case ENOTCONN:
case ECONNRESET:
stopAllActivities(stopIssued);
continue;
default:
Fatal(err);
break;
}
}
// demarshall the header
hdr.demarshall();
if (cmdArgs->logSseMessages()) {
LogWarning(ERR_NE, hdr.activityId,
"bad msg from Sse, code = %d, len = %d", hdr.code,
hdr.dataLength);
}
// allocate a message to hold the incoming message
Msg *msg = msgList->alloc();
msg->setHeader(hdr);
msg->setUnit((sonata_lib::Unit) UnitSse);
// if there's data associated with the message,
// allocate space and retrieve it, demarshall it
// based on the message type,
// then send it on to the command processor
void *data = 0;
int32_t len = hdr.dataLength;
timeval tv;
gettimeofday(&tv, NULL);
if (len > 10000) {
LogWarning(ERR_NE, hdr.activityId,
"msg code = %d, len = %d, t = %u, last msg = %d, last len = %d, last t = %u",
hdr.code, len, tv.tv_sec, lastCode, lastLen, lastTime);
Timer t;
t.sleep(100);
}
else {
lastCode = hdr.code;
lastLen = len;
lastTime = tv.tv_sec;
}
if (len) {
MemBlk *blk = partitionSet->alloc(len);
Assert(blk);
if (!blk)
Fatal(ERR_MAF);
data = blk->getData();
err = sse->recv(data, len);
if (err) {
switch (err) {
case EAGAIN:
case EINTR:
case ENOTCONN:
//.........这里部分代码省略.........