cmRtNet.h/c : cmRtNetSyncMsg_t is now has public visibility.

This commit is contained in:
kpl 2014-06-14 14:59:28 -07:00
parent 69ebc1c232
commit 059d9d5e08
2 changed files with 31 additions and 23 deletions

View File

@ -6,9 +6,9 @@
#include "cmMallocDebug.h" #include "cmMallocDebug.h"
#include "cmLinkedHeap.h" #include "cmLinkedHeap.h"
#include "cmUdpPort.h" #include "cmUdpPort.h"
#include "cmRtSysMsg.h"
#include "cmRtNet.h" #include "cmRtNet.h"
#include "cmTime.h" #include "cmTime.h"
#include "cmRtSysMsg.h"
#include "cmText.h" #include "cmText.h"
// flags for cmRtNetNode_t.flags; // flags for cmRtNetNode_t.flags;
@ -24,15 +24,6 @@ enum
kReportSyncNetFl = 0x01 kReportSyncNetFl = 0x01
}; };
typedef enum
{
kHelloSelNetId, // broadcast msg (label=node label, id=endpt cnt)
kNodeSelNetId, // define remote node (label=remote node label, id=endpt cnt)
kEndpointSelNetId, // define remote endpt (label=remote endpt label, id=endpt id)
kDoneSelNetId, // declare all endpts sent
kInvalidSelNetId
} cmRtNetSelId_t;
struct cmRtNetNode_str; struct cmRtNetNode_str;
typedef struct cmRtNetEnd_str typedef struct cmRtNetEnd_str
@ -73,16 +64,6 @@ typedef struct
cmChar_t* bcastAddr; // Network broadcast address cmChar_t* bcastAddr; // Network broadcast address
} cmRtNet_t; } cmRtNet_t;
// Network synchronization message format
typedef struct
{
cmRtSysMsgHdr_t hdr; // standard cmRtSys msg header
cmRtNetSelId_t selId; // message selector id (See kXXXSelNetId above)
const cmChar_t* label; // node or endpoint label
unsigned id; // endptCnt or endpoint id
unsigned rtSubIdx; // cmInvalidIdx or rtSubIdx
} cmRtNetSyncMsg_t;
cmRtNetH_t cmRtNetNullHandle = cmSTATIC_NULL_HANDLE; cmRtNetH_t cmRtNetNullHandle = cmSTATIC_NULL_HANDLE;
cmRtNetEndptH_t cmRtNetEndptNullHandle = cmSTATIC_NULL_HANDLE; cmRtNetEndptH_t cmRtNetEndptNullHandle = cmSTATIC_NULL_HANDLE;
@ -615,7 +596,7 @@ void _cmRtNetRecv( void* cbArg, const char* data, unsigned dataByteCnt, const st
if( _cmRtNetIsSyncModeMsg(data,dataByteCnt)) if( _cmRtNetIsSyncModeMsg(data,dataByteCnt))
_cmRtNetSyncModeRecv(p,data,dataByteCnt,fromAddr); _cmRtNetSyncModeRecv(p,data,dataByteCnt,fromAddr);
// else
p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr); p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr);
} }

View File

@ -30,6 +30,33 @@ extern "C" {
extern cmRtNetH_t cmRtNetNullHandle; extern cmRtNetH_t cmRtNetNullHandle;
extern cmRtNetEndptH_t cmRtNetEndptNullHandle; extern cmRtNetEndptH_t cmRtNetEndptNullHandle;
// selector id's for cmRtNetSyncMsg_t.selId.
typedef enum
{
kHelloSelNetId, // broadcast msg (label=node label, id=endpt cnt)
kNodeSelNetId, // define remote node (label=remote node label, id=endpt cnt)
kEndpointSelNetId, // define remote endpt (label=remote endpt label, id=endpt id)
kDoneSelNetId, // declare all endpts sent
kInvalidSelNetId
} cmRtNetSelId_t;
// Network synchronization message format.
// cmRtNetRC_t.hdr.selId == kNetSyncSelRtid.
typedef struct
{
cmRtSysMsgHdr_t hdr; // standard cmRtSys msg header
cmRtNetSelId_t selId; // message selector id (See kXXXSelNetId above)
const cmChar_t* label; // node or endpoint label
unsigned id; // endptCnt or endpoint id
unsigned rtSubIdx; // cmInvalidIdx or rtSubIdx
} cmRtNetSyncMsg_t;
// NOTE: Messages passed between cmRtNet nodes during the synchronization
// process use the cmRtNetSyncMsg_t format (w/ the body of label following
// the record. All other messages use cmRtNetMsg_t (cmRtSysMsg.h) format.
// 'cbFunc' will be called within the context of cmRtNetReceive() to receive // 'cbFunc' will be called within the context of cmRtNetReceive() to receive
// incoming network messages. // incoming network messages.
cmRtNetRC_t cmRtNetAlloc( cmCtx_t* ctx, cmRtNetH_t* hp, cmUdpCallback_t cbFunc, void* cbArg ); cmRtNetRC_t cmRtNetAlloc( cmCtx_t* ctx, cmRtNetH_t* hp, cmUdpCallback_t cbFunc, void* cbArg );
@ -67,7 +94,7 @@ extern "C" {
// This function must be polled to receive incoming network messages // This function must be polled to receive incoming network messages
// via the callback funcion 'cbFunc' as passed to cmRtNetAlloc(). // via the callback funcion 'cbFunc' as passed to cmRtNetAlloc().
// Note that all messages received via 'cbFunc' will be prefixed with // Note that all messages received via 'cbFunc' will be prefixed with
// an cmRtNetMsg_t header (See cmRtSysMsg.h). // an cmRtSysMsgHdr_t header (See cmRtSysMsg.h).
cmRtNetRC_t cmRtNetReceive( cmRtNetH_t h ); cmRtNetRC_t cmRtNetReceive( cmRtNetH_t h );
// Get an end point handle for use with cmRtNetSend. // Get an end point handle for use with cmRtNetSend.