@@ -128,7 +128,9 @@ func chardevListener(chardev *os.File, resp chan []byte) {
128
128
fmt .Printf ("%d bytes consumed\n " , n )
129
129
fmt .Printf ("%v\n " , message )
130
130
fmt .Println (message )
131
- fmt .Println (err )
131
+ if err != nil {
132
+ fmt .Printf ("Err: %v\n " , err )
133
+ }
132
134
133
135
if err == io .EOF {
134
136
break
@@ -139,23 +141,33 @@ func chardevListener(chardev *os.File, resp chan []byte) {
139
141
continue
140
142
}
141
143
142
- msgType := _req [0 ]
144
+ msgType := _req [0 ].Int ()
145
+ fmt .Printf ("MsgType: %d\n " , msgType )
143
146
144
147
fmt .Println ("before response" )
145
148
146
- if msgType . Int () == RESPONSE {
149
+ if msgType == RESPONSE {
147
150
fmt .Println ("got response and continue" )
148
151
// unlock thread waiting on handleConnection
149
152
resp <- copy_data [:n ]
150
153
continue
151
154
}
152
155
153
- fmt . Println ( "before serving" )
156
+ var msgFunction reflect. Value
154
157
155
- msgFunction := _req [2 ]
156
- port := functionToPort (string (msgFunction .Bytes ()))
158
+ if msgType == REQUEST {
159
+ msgFunction = _req [2 ]
160
+ }
161
+
162
+ if msgType == NOTIFICATION {
163
+ msgFunction = _req [1 ]
164
+ }
165
+
166
+ fmt .Println ("before serving" )
167
+ method := string (msgFunction .Bytes ())
168
+ port := functionToPort (method )
157
169
158
- fmt .Println ("Serving function " , string ( msgFunction . Bytes ()) , " to port " , port )
170
+ fmt .Println ("Serving function " , method , " to port " , port )
159
171
160
172
// REQUEST or NOTIFICATION
161
173
conn , err := net .Dial ("tcp" , port )
@@ -165,7 +177,7 @@ func chardevListener(chardev *os.File, resp chan []byte) {
165
177
}
166
178
conn .Write (copy_data [:n ])
167
179
168
- if msgType . Int () == REQUEST {
180
+ if msgType == REQUEST {
169
181
fmt .Println ("ask for a response" )
170
182
171
183
var to_send []byte
@@ -183,7 +195,8 @@ func chardevListener(chardev *os.File, resp chan []byte) {
183
195
chardev .Write (to_send [:i ])
184
196
}
185
197
186
- if msgType .Int () == NOTIFICATION {
198
+ if msgType == NOTIFICATION {
199
+ fmt .Println ("got a notification" )
187
200
// fire and forget
188
201
}
189
202
0 commit comments