diff --git a/cmRtNet.c b/cmRtNet.c index 1ecdfc2..53ec38f 100644 --- a/cmRtNet.c +++ b/cmRtNet.c @@ -6,9 +6,9 @@ #include "cmMallocDebug.h" #include "cmLinkedHeap.h" #include "cmUdpPort.h" +#include "cmRtSysMsg.h" #include "cmRtNet.h" #include "cmTime.h" -#include "cmRtSysMsg.h" #include "cmText.h" // flags for cmRtNetNode_t.flags; @@ -24,15 +24,6 @@ enum 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; typedef struct cmRtNetEnd_str @@ -73,16 +64,6 @@ typedef struct cmChar_t* bcastAddr; // Network broadcast address } 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; cmRtNetEndptH_t cmRtNetEndptNullHandle = cmSTATIC_NULL_HANDLE; @@ -615,8 +596,8 @@ void _cmRtNetRecv( void* cbArg, const char* data, unsigned dataByteCnt, const st if( _cmRtNetIsSyncModeMsg(data,dataByteCnt)) _cmRtNetSyncModeRecv(p,data,dataByteCnt,fromAddr); - // else - p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr); + + p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr); } diff --git a/cmRtNet.h b/cmRtNet.h index 06bda20..47d4ebb 100644 --- a/cmRtNet.h +++ b/cmRtNet.h @@ -30,6 +30,33 @@ extern "C" { extern cmRtNetH_t cmRtNetNullHandle; 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 // incoming network messages. 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 // via the callback funcion 'cbFunc' as passed to cmRtNetAlloc(). // 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 ); // Get an end point handle for use with cmRtNetSend.