aboutsummaryrefslogtreecommitdiff
path: root/test_msgnet
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-21 14:36:19 -0400
committerDeterminant <[email protected]>2019-06-21 14:36:19 -0400
commit988748a02d39228017e36f7a5c3415b19b31657d (patch)
tree197a5758fc3a9e1ec00b88020d11a9d2dbbbe58b /test_msgnet
parent720096e3dcc84cc0ab821841fdae249a4a029758 (diff)
parentb58ed6653f5e9ccd2d52239e8a26bfc9ae4cb061 (diff)
Merge branch 'master' of github.com:Determinant/salticidae-go
Diffstat (limited to 'test_msgnet')
-rw-r--r--test_msgnet/main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/test_msgnet/main.go b/test_msgnet/main.go
index 4e52982..66d7287 100644
--- a/test_msgnet/main.go
+++ b/test_msgnet/main.go
@@ -34,10 +34,10 @@ func msgHelloSerialize(name string, text string) salticidae.Msg {
}
func msgHelloUnserialize(msg salticidae.Msg) (name string, text string) {
- p := msg.ConsumePayload()
- length := binary.LittleEndian.Uint32(p.GetDataInPlace(4))
- name = string(p.GetDataInPlace(int(length)))
- text = string(p.GetDataInPlace(p.Size()))
+ p := msg.GetPayloadByMove()
+ t := p.GetDataInPlace(4); length := binary.LittleEndian.Uint32(t.Get()); t.Release()
+ t = p.GetDataInPlace(int(length)); name = string(t.Get()); t.Release()
+ t = p.GetDataInPlace(p.Size()); text = string(t.Get()); t.Release()
return
}
@@ -79,7 +79,7 @@ func onReceiveHello(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, _ u
name, text := msgHelloUnserialize(msg)
fmt.Printf("[%s] %s says %s\n", myName, name, text)
ack := msgAckSerialize()
- net.SendMsgByMove(ack, conn)
+ net.SendMsg(ack, conn)
}
//export onReceiveAck
@@ -106,7 +106,7 @@ func connHandler(_conn *C.struct_msgnetwork_conn_t, connected C.bool, _ unsafe.P
if conn.GetMode() == salticidae.CONN_MODE_ACTIVE {
fmt.Printf("[%s] Connected, sending hello.\n", name)
hello := msgHelloSerialize(name, "Hello there!")
- n.net.SendMsgByMove(hello, conn)
+ n.net.SendMsg(hello, conn)
} else {
fmt.Printf("[%s] Accepted, waiting for greetings.\n", name)
}