Browse Source

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

master
kpl 10 years ago
parent
commit
059d9d5e08
2 changed files with 31 additions and 23 deletions
  1. 3
    22
      cmRtNet.c
  2. 28
    1
      cmRtNet.h

+ 3
- 22
cmRtNet.c View File

@@ -6,9 +6,9 @@
6 6
 #include "cmMallocDebug.h"
7 7
 #include "cmLinkedHeap.h"
8 8
 #include "cmUdpPort.h"
9
+#include "cmRtSysMsg.h"
9 10
 #include "cmRtNet.h"
10 11
 #include "cmTime.h"
11
-#include "cmRtSysMsg.h"
12 12
 #include "cmText.h"
13 13
 
14 14
 // flags for cmRtNetNode_t.flags;
@@ -24,15 +24,6 @@ enum
24 24
   kReportSyncNetFl = 0x01
25 25
 };
26 26
 
27
-typedef enum
28
-{
29
-  kHelloSelNetId,         // broadcast msg (label=node label, id=endpt cnt)
30
-  kNodeSelNetId,          // define remote node  (label=remote node label, id=endpt cnt)
31
-  kEndpointSelNetId,      // define remote endpt (label=remote endpt label, id=endpt id)
32
-  kDoneSelNetId,          // declare all endpts sent
33
-  kInvalidSelNetId
34
-} cmRtNetSelId_t;
35
-
36 27
 struct cmRtNetNode_str;
37 28
 
38 29
 typedef struct cmRtNetEnd_str
@@ -73,16 +64,6 @@ typedef struct
73 64
   cmChar_t*       bcastAddr;             // Network broadcast address
74 65
 } cmRtNet_t;
75 66
 
76
-// Network synchronization message format
77
-typedef struct
78
-{
79
-  cmRtSysMsgHdr_t hdr;      // standard cmRtSys msg  header 
80
-  cmRtNetSelId_t  selId;    // message selector id (See kXXXSelNetId above)
81
-  const cmChar_t* label;    // node         or endpoint label
82
-  unsigned        id;       // endptCnt     or endpoint id
83
-  unsigned        rtSubIdx; // cmInvalidIdx or rtSubIdx
84
-} cmRtNetSyncMsg_t;
85
-
86 67
 cmRtNetH_t      cmRtNetNullHandle      = cmSTATIC_NULL_HANDLE;
87 68
 cmRtNetEndptH_t cmRtNetEndptNullHandle = cmSTATIC_NULL_HANDLE;
88 69
 
@@ -615,8 +596,8 @@ void _cmRtNetRecv( void* cbArg, const char* data, unsigned dataByteCnt, const st
615 596
   
616 597
   if( _cmRtNetIsSyncModeMsg(data,dataByteCnt))
617 598
     _cmRtNetSyncModeRecv(p,data,dataByteCnt,fromAddr);
618
-  // else
619
-    p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr);
599
+  
600
+  p->cbFunc(p->cbArg,data,dataByteCnt,fromAddr);
620 601
   
621 602
 }
622 603
 

+ 28
- 1
cmRtNet.h View File

@@ -30,6 +30,33 @@ extern "C" {
30 30
   extern cmRtNetH_t      cmRtNetNullHandle;
31 31
   extern cmRtNetEndptH_t cmRtNetEndptNullHandle;
32 32
 
33
+
34
+  // selector id's for cmRtNetSyncMsg_t.selId.
35
+  typedef enum
36
+  {
37
+    kHelloSelNetId,         // broadcast msg (label=node label, id=endpt cnt)
38
+    kNodeSelNetId,          // define remote node  (label=remote node label,  id=endpt cnt)
39
+    kEndpointSelNetId,      // define remote endpt (label=remote endpt label, id=endpt id)
40
+    kDoneSelNetId,          // declare all endpts sent
41
+    kInvalidSelNetId
42
+  } cmRtNetSelId_t;
43
+
44
+
45
+  // Network synchronization message format.
46
+  // cmRtNetRC_t.hdr.selId == kNetSyncSelRtid.
47
+  typedef struct
48
+  {
49
+    cmRtSysMsgHdr_t hdr;      // standard cmRtSys msg  header 
50
+    cmRtNetSelId_t  selId;    // message selector id (See kXXXSelNetId above)
51
+    const cmChar_t* label;    // node         or endpoint label
52
+    unsigned        id;       // endptCnt     or endpoint id
53
+    unsigned        rtSubIdx; // cmInvalidIdx or rtSubIdx
54
+  } cmRtNetSyncMsg_t;
55
+
56
+  // NOTE: Messages passed between cmRtNet nodes during the synchronization 
57
+  // process use the cmRtNetSyncMsg_t format (w/ the body of label following 
58
+  // the record.  All other messages use cmRtNetMsg_t (cmRtSysMsg.h) format.
59
+
33 60
   // 'cbFunc' will be called within the context of cmRtNetReceive() to receive
34 61
   // incoming network messages.
35 62
   cmRtNetRC_t cmRtNetAlloc( cmCtx_t* ctx, cmRtNetH_t* hp, cmUdpCallback_t cbFunc, void* cbArg );
@@ -67,7 +94,7 @@ extern "C" {
67 94
   // This function must be polled to receive incoming network messages
68 95
   // via the callback funcion 'cbFunc' as passed to cmRtNetAlloc().
69 96
   // Note that all messages received via 'cbFunc' will be prefixed with
70
-  // an cmRtNetMsg_t header (See cmRtSysMsg.h).
97
+  // an cmRtSysMsgHdr_t header (See cmRtSysMsg.h).
71 98
   cmRtNetRC_t cmRtNetReceive( cmRtNetH_t h );
72 99
 
73 100
   // Get an end point handle for use with cmRtNetSend.

Loading…
Cancel
Save