From 1d71aba0a7c7d32c4188db801897a51ddfae865d Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 7 Jun 2019 23:18:36 -0400 Subject: ... --- network.go | 33 +++++++++++++++++++++++++++++++++ salticidae | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/network.go b/network.go index 572c1cc..9b5b07d 100644 --- a/network.go +++ b/network.go @@ -55,3 +55,36 @@ func (self MsgNetwork) RegHandler(opcode Opcode, callback MsgNetworkMsgCallback) func (self MsgNetwork) RegConnHandler(callback MsgNetworkConnCallback) { C.msgnetwork_reg_conn_handler(self, callback) } + +type PeerNetwork = *C.struct_peernetwork_t + +type PeerNetworkConn = *C.struct_peernetwork_conn_t + +type PeerNetworkConfig = *C.struct_peernetwork_config_t + +func NewPeerNetworkConfig() PeerNetworkConfig { return C.peernetwork_config_new() } + +func NewPeerNetwork(ec EventContext, config PeerNetworkConfig) PeerNetwork { + return C.peernetwork_new(ec, config) +} + +func (self PeerNetwork) Free() { C.peernetwork_free(self) } + +func (self PeerNetwork) AddPeer(paddr NetAddr) { C.peernetwork_add_peer(self, paddr) } + +func (self PeerNetwork) HasPeer(paddr NetAddr) bool { return bool(C.peernetwork_has_peer(self, paddr)) } + +func (self PeerNetwork) GetPeerConn(paddr NetAddr) PeerNetworkConn { return C.peernetwork_get_peer_conn(self, paddr) } + +func (self PeerNetwork) AsMsgNetwork() MsgNetwork { return C.peernetwork_as_msgnetwork(self) } + +func NewMsgNetworkConnFromPeerNetWorkConn(conn PeerNetworkConn) MsgNetworkConn { return C.msgnetwork_conn_new_from_peernetwork_conn(conn) } + +func (self PeerNetwork) SendMsg(_moved_msg Msg, paddr NetAddr) { C.peernetwork_send_msg(self, _moved_msg, paddr) } + +func (self PeerNetwork) MulticastMsg(_moved_msg Msg, paddrs []NetAddr) { + base := uintptr(rawptr_t(&paddrs[0])) + C.peernetwork_multicast_msg(self, _moved_msg, (*C.struct_netaddr_t)(rawptr_t(base)), C.size_t(len(paddrs))) +} + +func (self PeerNetwork) Listen(listenAddr NetAddr) { C.peernetwork_listen(self, listenAddr) } diff --git a/salticidae b/salticidae index 0f3b3ed..1f5bffd 160000 --- a/salticidae +++ b/salticidae @@ -1 +1 @@ -Subproject commit 0f3b3ed832db7062c805e82a9605b777595e340c +Subproject commit 1f5bffd006ef432a2fa12fe5baf03c7160c42f73 -- cgit v1.2.3-70-g09d2