Showing
1 changed file
with
19 additions
and
14 deletions
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | +#include <inttypes.h> | ||
3 | 4 | ||
4 | #include "trbase.h" | 5 | #include "trbase.h" |
5 | #include "trcomm.h" | 6 | #include "trcomm.h" |
@@ -15,16 +16,17 @@ TR_CLASSVARS_DECL(TestHandler) { | @@ -15,16 +16,17 @@ TR_CLASSVARS_DECL(TestHandler) { | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | static | 18 | static |
18 | -int | 19 | +TR_EventDone |
19 | testHandlerHeartbeat(TR_EventHandler this, TR_Event event) | 20 | testHandlerHeartbeat(TR_EventHandler this, TR_Event event) |
20 | { | 21 | { |
21 | printf("handled: %llu/s\n", ((TestHandler)this)->handled); | 22 | printf("handled: %llu/s\n", ((TestHandler)this)->handled); |
22 | ((TestHandler)this)->handled = 0; | 23 | ((TestHandler)this)->handled = 0; |
23 | - return FALSE; | 24 | + |
25 | + return TR_EVENT_DONE; | ||
24 | } | 26 | } |
25 | 27 | ||
26 | static | 28 | static |
27 | -int | 29 | +TR_EventDone |
28 | testHandlerNewMessage(TR_EventHandler this, TR_Event event) | 30 | testHandlerNewMessage(TR_EventHandler this, TR_Event event) |
29 | { | 31 | { |
30 | TR_ProtoMessageRaw msg = event->data; | 32 | TR_ProtoMessageRaw msg = event->data; |
@@ -43,27 +45,30 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) | @@ -43,27 +45,30 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event) | ||
43 | 45 | ||
44 | TR_eventHandlerIssueEvent( | 46 | TR_eventHandlerIssueEvent( |
45 | (TR_EventHandler)this, | 47 | (TR_EventHandler)this, |
46 | - event->subject, | ||
47 | - TR_CEP_EVENT_SEND_MSG, | ||
48 | - event->data); | 48 | + TR_eventSubjectEmit( |
49 | + event->subject, | ||
50 | + TR_CEP_EVENT_SEND_MSG, | ||
51 | + event->data)); | ||
49 | 52 | ||
50 | - return FALSE; | 53 | + return TR_EVENT_DONE; |
51 | } | 54 | } |
52 | 55 | ||
53 | static | 56 | static |
54 | -int | 57 | +TR_EventDone |
55 | testHandlerClose(TR_EventHandler this, TR_Event event) | 58 | testHandlerClose(TR_EventHandler this, TR_Event event) |
56 | { | 59 | { |
57 | puts("close"); | 60 | puts("close"); |
58 | - return FALSE; | 61 | + |
62 | + return TR_EVENT_PENDING; | ||
59 | } | 63 | } |
60 | 64 | ||
61 | static | 65 | static |
62 | -int | 66 | +TR_EventDone |
63 | testHandlerUpgrade(TR_EventHandler this, TR_Event event) | 67 | testHandlerUpgrade(TR_EventHandler this, TR_Event event) |
64 | { | 68 | { |
65 | - puts("upgrade"); | ||
66 | - return FALSE; | 69 | + printf("upgrade: %"PRIdPTR"\n", event->id); |
70 | + | ||
71 | + return TR_EVENT_PENDING; | ||
67 | } | 72 | } |
68 | 73 | ||
69 | static | 74 | static |
@@ -99,12 +104,12 @@ testHandlerCvInit(TR_class_ptr class) | @@ -99,12 +104,12 @@ testHandlerCvInit(TR_class_ptr class) | ||
99 | testHandlerNewMessage); | 104 | testHandlerNewMessage); |
100 | TR_EVENT_HANDLER_SET_METHOD( | 105 | TR_EVENT_HANDLER_SET_METHOD( |
101 | class, | 106 | class, |
102 | - TR_EventDispatcher, | 107 | + TR_CommEndPoint, |
103 | TR_CEP_EVENT_CLOSE, | 108 | TR_CEP_EVENT_CLOSE, |
104 | testHandlerClose); | 109 | testHandlerClose); |
105 | TR_EVENT_HANDLER_SET_METHOD( | 110 | TR_EVENT_HANDLER_SET_METHOD( |
106 | class, | 111 | class, |
107 | - TR_EventDispatcher, | 112 | + TR_CommEndPoint, |
108 | TR_CEP_EVENT_UPGRADE, | 113 | TR_CEP_EVENT_UPGRADE, |
109 | testHandlerUpgrade); | 114 | testHandlerUpgrade); |
110 | } | 115 | } |
Please
register
or
login
to post a comment