aboutsummaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-07 22:06:56 -0400
committerDeterminant <[email protected]>2019-06-07 22:06:56 -0400
commit3a8f691708ab6bb047c94c7ce2b40e83e821a979 (patch)
treefef7854ca2fcd397aea8b4bb9f95dd65cbaed186 /demo
parent4a37b259717e545c090fb11b6a36f7e75118c2f9 (diff)
the first MsgNetwork example is working
Diffstat (limited to 'demo')
-rw-r--r--demo/main.go44
-rw-r--r--demo/main_.go7
2 files changed, 0 insertions, 51 deletions
diff --git a/demo/main.go b/demo/main.go
deleted file mode 100644
index 8dcbe98..0000000
--- a/demo/main.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-// void onTerm_cgo(int sig);
-import "C"
-
-import "salticidae-go"
-import "unsafe"
-
-var ec salticidae.EventContext
-
-//export onTerm
-func onTerm(_ int) {
- ec.Stop()
-}
-
-func run(ec salticidae.EventContext, my_addr string, other_addr string) salticidae.MsgNetwork {
- netconfig := salticidae.NewMsgNetworkConfig()
- net := salticidae.NewMsgNetwork(ec, netconfig)
- listen_addr := salticidae.NewAddrFromIPPortString(my_addr)
- connect_addr := salticidae.NewAddrFromIPPortString(other_addr)
-
- net.Start()
- net.Listen(listen_addr)
- net.Connect(connect_addr)
- return net
-}
-
-func main() {
- ec = salticidae.NewEventContext()
- ev_int := salticidae.NewSigEvent(ec, salticidae.SigEventCallback(unsafe.Pointer(C.onTerm_cgo)))
- ev_int.Add(salticidae.SIGINT)
- ev_term := salticidae.NewSigEvent(ec, salticidae.SigEventCallback(unsafe.Pointer(C.onTerm_cgo)))
- ev_term.Add(salticidae.SIGTERM)
-
- alice := "127.0.0.1:10000"
- bob := "127.0.0.1:10001"
- alice_net := run(ec, alice, bob)
- bob_net := run(ec, bob, alice)
- ec.Dispatch()
- ev_int.Free()
- ev_term.Free()
- alice_net.Free()
- bob_net.Free()
-}
diff --git a/demo/main_.go b/demo/main_.go
deleted file mode 100644
index 2f53d93..0000000
--- a/demo/main_.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package main
-
-// void onTerm_cgo(int sig) {
-// void onTerm(int);
-// onTerm(sig);
-// }
-import "C"