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