aboutsummaryrefslogtreecommitdiff
path: root/test_msgnet_tls
diff options
context:
space:
mode:
Diffstat (limited to 'test_msgnet_tls')
-rw-r--r--test_msgnet_tls/main.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/test_msgnet_tls/main.go b/test_msgnet_tls/main.go
index b14cedd..1d613fd 100644
--- a/test_msgnet_tls/main.go
+++ b/test_msgnet_tls/main.go
@@ -11,7 +11,6 @@ package main
import "C"
import (
- "encoding/binary"
"os"
"fmt"
"unsafe"
@@ -25,9 +24,7 @@ const (
func msgHelloSerialize(name string, text string) salticidae.Msg {
serialized := salticidae.NewDataStream()
- t := make([]byte, 4)
- binary.LittleEndian.PutUint32(t, uint32(len(name)))
- serialized.PutData(t)
+ serialized.PutU32(salticidae.ToLittleEndianU32(uint32(len(name))))
serialized.PutData([]byte(name))
serialized.PutData([]byte(text))
return salticidae.NewMsgMovedFromByteArray(
@@ -36,8 +33,9 @@ func msgHelloSerialize(name string, text string) salticidae.Msg {
func msgHelloUnserialize(msg salticidae.Msg) (name string, text string) {
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()
+ succ := true
+ length := salticidae.FromLittleEndianU32(p.GetU32(&succ))
+ t := p.GetDataInPlace(int(length)); name = string(t.Get()); t.Release()
t = p.GetDataInPlace(p.Size()); text = string(t.Get()); t.Release()
return
}
@@ -151,9 +149,10 @@ func genMyNet(ec salticidae.EventContext,
func main() {
ec = salticidae.NewEventContext()
+ err := salticidae.NewError()
- aliceAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12345")
- bobAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12346")
+ aliceAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12345", &err)
+ bobAddr := salticidae.NewAddrFromIPPortString("127.0.0.1:12346", &err)
alice = genMyNet(ec, "alice", "ed5a9a8c7429dcb235a88244bc69d43d16b35008ce49736b27aaa3042a674043", aliceAddr, bobAddr)
bob = genMyNet(ec, "bob", "ef3bea4e72f4d0e85da7643545312e2ff6dded5e176560bdffb1e53b1cef4896", bobAddr, aliceAddr)