Browse Source

update testserver

1.0.0
Georg Hopp 11 years ago
parent
commit
df3b337f2c
  1. 33
      testers/testserver.c

33
testers/testserver.c

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <inttypes.h>
#include "trbase.h" #include "trbase.h"
#include "trcomm.h" #include "trcomm.h"
@ -15,16 +16,17 @@ TR_CLASSVARS_DECL(TestHandler) {
}; };
static static
int
TR_EventDone
testHandlerHeartbeat(TR_EventHandler this, TR_Event event) testHandlerHeartbeat(TR_EventHandler this, TR_Event event)
{ {
printf("handled: %llu/s\n", ((TestHandler)this)->handled); printf("handled: %llu/s\n", ((TestHandler)this)->handled);
((TestHandler)this)->handled = 0; ((TestHandler)this)->handled = 0;
return FALSE;
return TR_EVENT_DONE;
} }
static static
int
TR_EventDone
testHandlerNewMessage(TR_EventHandler this, TR_Event event) testHandlerNewMessage(TR_EventHandler this, TR_Event event)
{ {
TR_ProtoMessageRaw msg = event->data; TR_ProtoMessageRaw msg = event->data;
@ -43,27 +45,30 @@ testHandlerNewMessage(TR_EventHandler this, TR_Event event)
TR_eventHandlerIssueEvent( TR_eventHandlerIssueEvent(
(TR_EventHandler)this, (TR_EventHandler)this,
event->subject,
TR_CEP_EVENT_SEND_MSG,
event->data);
TR_eventSubjectEmit(
event->subject,
TR_CEP_EVENT_SEND_MSG,
event->data));
return FALSE;
return TR_EVENT_DONE;
} }
static static
int
TR_EventDone
testHandlerClose(TR_EventHandler this, TR_Event event) testHandlerClose(TR_EventHandler this, TR_Event event)
{ {
puts("close"); puts("close");
return FALSE;
return TR_EVENT_PENDING;
} }
static static
int
TR_EventDone
testHandlerUpgrade(TR_EventHandler this, TR_Event event) testHandlerUpgrade(TR_EventHandler this, TR_Event event)
{ {
puts("upgrade");
return FALSE;
printf("upgrade: %"PRIdPTR"\n", event->id);
return TR_EVENT_PENDING;
} }
static static
@ -99,12 +104,12 @@ testHandlerCvInit(TR_class_ptr class)
testHandlerNewMessage); testHandlerNewMessage);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
class, class,
TR_EventDispatcher,
TR_CommEndPoint,
TR_CEP_EVENT_CLOSE, TR_CEP_EVENT_CLOSE,
testHandlerClose); testHandlerClose);
TR_EVENT_HANDLER_SET_METHOD( TR_EVENT_HANDLER_SET_METHOD(
class, class,
TR_EventDispatcher,
TR_CommEndPoint,
TR_CEP_EVENT_UPGRADE, TR_CEP_EVENT_UPGRADE,
testHandlerUpgrade); testHandlerUpgrade);
} }

Loading…
Cancel
Save