|
@@ -25,10 +25,7 @@ |
|
@@ -25,10 +25,7 @@ |
25
|
#include "trbase.h"
|
25
|
#include "trbase.h"
|
26
|
#include "trevent.h"
|
26
|
#include "trevent.h"
|
27
|
|
27
|
|
28
|
-#include "tr/protocol.h"
|
|
|
29
|
-#include "tr/connection.h"
|
|
|
30
|
-#include "tr/protocol_handler.h"
|
|
|
31
|
-#include "tr/proto_message.h"
|
28
|
+#include "tr/io_handler.h"
|
32
|
#include "tr/comm_end_point.h"
|
29
|
#include "tr/comm_end_point.h"
|
33
|
#include "tr/interface/comm_end_point.h"
|
30
|
#include "tr/interface/comm_end_point.h"
|
34
|
|
31
|
|
|
@@ -47,11 +44,15 @@ static |
|
@@ -47,11 +44,15 @@ static |
47
|
int
|
44
|
int
|
48
|
ioHandlerRead(void * _this, TR_Event event)
|
45
|
ioHandlerRead(void * _this, TR_Event event)
|
49
|
{
|
46
|
{
|
50
|
- /**
|
|
|
51
|
- * TODO No upgrade for now. Add it later on.
|
|
|
52
|
- */
|
|
|
53
|
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject;
|
47
|
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject;
|
54
|
- TR_ProtoMessage message = TR_cepNextMessage(endpoint);
|
48
|
+
|
|
|
49
|
+ if (TR_cepBufferRead(endpoint)) {
|
|
|
50
|
+ TR_eventHandlerIssueEvent(
|
|
|
51
|
+ (TR_EventHandler)_this,
|
|
|
52
|
+ event->subject,
|
|
|
53
|
+ TR_CEP_EVENT_NEW_DATA,
|
|
|
54
|
+ NULL);
|
|
|
55
|
+ }
|
55
|
|
56
|
|
56
|
return TRUE;
|
57
|
return TRUE;
|
57
|
}
|
58
|
}
|
|
@@ -61,12 +62,21 @@ int |
|
@@ -61,12 +62,21 @@ int |
61
|
ioHandlerWrite(void * _this, TR_Event event)
|
62
|
ioHandlerWrite(void * _this, TR_Event event)
|
62
|
{
|
63
|
{
|
63
|
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject;
|
64
|
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject;
|
64
|
- TR_ProtoMessage message = (TR_ProtoMessage)event->data;
|
|
|
65
|
|
65
|
|
66
|
- if (message->close) {
|
|
|
67
|
- // also check that we are a response. Well this is how it is done
|
|
|
68
|
- // in the python code...
|
|
|
69
|
- TR_cepSetClose(endpoint);
|
66
|
+ if (TR_cepWriteBuffered(endpoint)) {
|
|
|
67
|
+ if (TR_cepHasPendingData(endpoint)) {
|
|
|
68
|
+ TR_eventHandlerIssueEvent(
|
|
|
69
|
+ (TR_EventHandler)_this,
|
|
|
70
|
+ event->subject,
|
|
|
71
|
+ TR_CEP_EVENT_PENDING_DATA,
|
|
|
72
|
+ NULL);
|
|
|
73
|
+ } else {
|
|
|
74
|
+ TR_eventHandlerIssueEvent(
|
|
|
75
|
+ (TR_EventHandler)_this,
|
|
|
76
|
+ event->subject,
|
|
|
77
|
+ TR_CEP_EVENT_END_DATA,
|
|
|
78
|
+ NULL);
|
|
|
79
|
+ }
|
70
|
}
|
80
|
}
|
71
|
|
81
|
|
72
|
return TRUE;
|
82
|
return TRUE;
|
|
@@ -74,17 +84,17 @@ ioHandlerWrite(void * _this, TR_Event event) |
|
@@ -74,17 +84,17 @@ ioHandlerWrite(void * _this, TR_Event event) |
74
|
|
84
|
|
75
|
static
|
85
|
static
|
76
|
void
|
86
|
void
|
77
|
-protocolHandlerCvInit(TR_class_ptr cls)
|
87
|
+ioHandlerCvInit(TR_class_ptr cls)
|
78
|
{
|
88
|
{
|
79
|
TR_EVENT_HANDLER_SET_METHOD(
|
89
|
TR_EVENT_HANDLER_SET_METHOD(
|
80
|
cls,
|
90
|
cls,
|
81
|
- TR_Connection,
|
91
|
+ TR_CommEndPoint,
|
82
|
TR_CEP_EVENT_READ_READY,
|
92
|
TR_CEP_EVENT_READ_READY,
|
83
|
ioHandlerRead);
|
93
|
ioHandlerRead);
|
84
|
|
94
|
|
85
|
TR_EVENT_HANDLER_SET_METHOD(
|
95
|
TR_EVENT_HANDLER_SET_METHOD(
|
86
|
cls,
|
96
|
cls,
|
87
|
- TR_Connection,
|
97
|
+ TR_CommEndPoint,
|
88
|
TR_CEP_EVENT_WRITE_READY,
|
98
|
TR_CEP_EVENT_WRITE_READY,
|
89
|
ioHandlerWrite);
|
99
|
ioHandlerWrite);
|
90
|
}
|
100
|
}
|
|
@@ -92,7 +102,7 @@ protocolHandlerCvInit(TR_class_ptr cls) |
|
@@ -92,7 +102,7 @@ protocolHandlerCvInit(TR_class_ptr cls) |
92
|
TR_INSTANCE(TR_Hash, ioHandlerEventMethods);
|
102
|
TR_INSTANCE(TR_Hash, ioHandlerEventMethods);
|
93
|
TR_INIT_IFACE(TR_Class, ioHandlerCtor, ioHandlerDtor, NULL);
|
103
|
TR_INIT_IFACE(TR_Class, ioHandlerCtor, ioHandlerDtor, NULL);
|
94
|
TR_CREATE_CLASS(
|
104
|
TR_CREATE_CLASS(
|
95
|
- TR_ProtocolHandler,
|
105
|
+ TR_IoHandler,
|
96
|
TR_EventHandler,
|
106
|
TR_EventHandler,
|
97
|
ioHandlerCvInit,
|
107
|
ioHandlerCvInit,
|
98
|
TR_IF(TR_Class)) = {
|
108
|
TR_IF(TR_Class)) = {
|