aboutsummaryrefslogtreecommitdiff
path: root/test_msgnet
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-14 18:17:53 -0400
committerDeterminant <[email protected]>2019-06-14 18:17:53 -0400
commit35d6ada17b298a9ce51c2e432596b91d7c6c4cc3 (patch)
treeab259080619dcdd654a3ef53325839fa48944f5b /test_msgnet
parentcb133a379998112600ea1504b556484a417cf48a (diff)
minor fix
Diffstat (limited to 'test_msgnet')
-rw-r--r--test_msgnet/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/test_msgnet/main.go b/test_msgnet/main.go
index ee262b7..4c885d3 100644
--- a/test_msgnet/main.go
+++ b/test_msgnet/main.go
@@ -6,6 +6,7 @@ package main
// void onReceiveHello(msg_t *, msgnetwork_conn_t *, void *);
// void onReceiveAck(msg_t *, msgnetwork_conn_t *, void *);
// void connHandler(msgnetwork_conn_t *, bool, void *);
+// void errorHandler(SalticidaeCError *, bool, void *);
import "C"
import (
@@ -120,6 +121,14 @@ func connHandler(_conn *C.struct_msgnetwork_conn_t, connected C.bool, _ unsafe.P
}
}
+//export errorHandler
+func errorHandler(_err *C.struct_SalticidaeCError, fatal C.bool, _ unsafe.Pointer) {
+ err := (*salticidae.Error)(unsafe.Pointer(_err))
+ s := "recoverable"
+ if fatal { s = "fatal" }
+ fmt.Printf("Captured %s error during an async call: %s\n", s, salticidae.StrError(err.GetCode()))
+}
+
func genMyNet(ec salticidae.EventContext, name string) MyNet {
netconfig := salticidae.NewMsgNetworkConfig()
n := MyNet {
@@ -129,6 +138,7 @@ func genMyNet(ec salticidae.EventContext, name string) MyNet {
n.net.RegHandler(MSG_OPCODE_HELLO, salticidae.MsgNetworkMsgCallback(C.onReceiveHello), nil)
n.net.RegHandler(MSG_OPCODE_ACK, salticidae.MsgNetworkMsgCallback(C.onReceiveAck), nil)
n.net.RegConnHandler(salticidae.MsgNetworkConnCallback(C.connHandler), nil)
+ n.net.RegErrorHandler(salticidae.MsgNetworkErrorCallback(C.errorHandler), nil)
netconfig.Free()
return n
}