diff options
-rw-r--r-- | network.go | 33 | ||||
m--------- | salticidae | 0 |
2 files changed, 33 insertions, 0 deletions
@@ -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 -Subproject 0f3b3ed832db7062c805e82a9605b777595e340 +Subproject 1f5bffd006ef432a2fa12fe5baf03c7160c42f7 |