Skip to content

Commit b9af564

Browse files
authored
Merge pull request #1 from manchoz/fix_rpc_notify
Fix MsgPack-RPC Notify management
2 parents 1d171ca + 7a63a4b commit b9af564

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

proxy/main.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ func chardevListener(chardev *os.File, resp chan []byte) {
128128
fmt.Printf("%d bytes consumed\n", n)
129129
fmt.Printf("%v\n", message)
130130
fmt.Println(message)
131-
fmt.Println(err)
131+
if err != nil {
132+
fmt.Printf("Err: %v\n", err)
133+
}
132134

133135
if err == io.EOF {
134136
break
@@ -139,23 +141,33 @@ func chardevListener(chardev *os.File, resp chan []byte) {
139141
continue
140142
}
141143

142-
msgType := _req[0]
144+
msgType := _req[0].Int()
145+
fmt.Printf("MsgType: %d\n", msgType)
143146

144147
fmt.Println("before response")
145148

146-
if msgType.Int() == RESPONSE {
149+
if msgType == RESPONSE {
147150
fmt.Println("got response and continue")
148151
// unlock thread waiting on handleConnection
149152
resp <- copy_data[:n]
150153
continue
151154
}
152155

153-
fmt.Println("before serving")
156+
var msgFunction reflect.Value
154157

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)
157169

158-
fmt.Println("Serving function ", string(msgFunction.Bytes()), " to port ", port)
170+
fmt.Println("Serving function ", method, " to port ", port)
159171

160172
// REQUEST or NOTIFICATION
161173
conn, err := net.Dial("tcp", port)
@@ -165,7 +177,7 @@ func chardevListener(chardev *os.File, resp chan []byte) {
165177
}
166178
conn.Write(copy_data[:n])
167179

168-
if msgType.Int() == REQUEST {
180+
if msgType == REQUEST {
169181
fmt.Println("ask for a response")
170182

171183
var to_send []byte
@@ -183,7 +195,8 @@ func chardevListener(chardev *os.File, resp chan []byte) {
183195
chardev.Write(to_send[:i])
184196
}
185197

186-
if msgType.Int() == NOTIFICATION {
198+
if msgType == NOTIFICATION {
199+
fmt.Println("got a notification")
187200
// fire and forget
188201
}
189202

0 commit comments

Comments
 (0)