From 720096e3dcc84cc0ab821841fdae249a4a029758 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 21 Jun 2019 14:27:17 -0400 Subject: ... --- network.go | 27 +++++++++++++++++++-------- salticidae | 2 +- stream.go | 10 ++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/network.go b/network.go index c30e3d3..04d653b 100644 --- a/network.go +++ b/network.go @@ -94,7 +94,14 @@ func (self MsgNetwork) Listen(addr NetAddr, err *Error) { C.msgnetwork_listen(se func (self MsgNetwork) Start() { C.msgnetwork_start(self.inner) } func (self MsgNetwork) Stop() { C.msgnetwork_stop(self.inner) } -func (self MsgNetwork) SendMsgByMove(msg Msg, conn MsgNetworkConn) { C.msgnetwork_send_msg_by_move(self.inner, msg.inner, conn.inner) } +func (self MsgNetwork) SendMsg(msg Msg, conn MsgNetworkConn) { + C.msgnetwork_send_msg(self.inner, msg.inner, conn.inner) +} + +func (self MsgNetwork) SendMsgDeferredByMove(msg Msg, conn MsgNetworkConn) { + C.msgnetwork_send_msg_deferred_by_move(self.inner, msg.inner, conn.inner) +} + func (self MsgNetwork) Connect(addr NetAddr, err *Error) MsgNetworkConn { res := MsgNetworkConnFromC(C.msgnetwork_connect(self.inner, addr.inner, err)) runtime.SetFinalizer(res, func(self MsgNetworkConn) { self.free() }) @@ -227,17 +234,21 @@ func (self PeerNetworkConn) Copy() PeerNetworkConn { func (self PeerNetworkConn) free() { C.peernetwork_conn_free(self.inner) } -func (self PeerNetwork) SendMsgByMove(_moved_msg Msg, paddr NetAddr) { - C.peernetwork_send_msg_by_move(self.inner, _moved_msg.inner, paddr.inner) +func (self PeerNetwork) Listen(listenAddr NetAddr, err *Error) { + C.peernetwork_listen(self.inner, listenAddr.inner, err) +} + +func (self PeerNetwork) SendMsg(msg Msg, addr NetAddr) { + C.peernetwork_send_msg(self.inner, msg.inner, addr.inner) } -func (self PeerNetwork) MulticastMsgByMove(_moved_msg Msg, paddrs []NetAddr) { - na := NewAddrArrayFromAddrs(paddrs) - C.peernetwork_multicast_msg_by_move(self.inner, _moved_msg.inner, na.inner) +func (self PeerNetwork) SendMsgDeferredByMove(msg Msg, addr NetAddr) { + C.peernetwork_send_msg_deferred_by_move(self.inner, msg.inner, addr.inner) } -func (self PeerNetwork) Listen(listenAddr NetAddr, err *Error) { - C.peernetwork_listen(self.inner, listenAddr.inner, err) +func (self PeerNetwork) MulticastMsgByMove(msg Msg, paddrs []NetAddr) { + na := NewAddrArrayFromAddrs(paddrs) + C.peernetwork_multicast_msg_by_move(self.inner, msg.inner, na.inner) } type MsgNetworkUnknownPeerCallback = C.msgnetwork_unknown_peer_callback_t diff --git a/salticidae b/salticidae index c69b015..823585c 160000 --- a/salticidae +++ b/salticidae @@ -1 +1 @@ -Subproject commit c69b0150fe0c50b91c7c8a406f096de8e9cf62fc +Subproject commit 823585c4db2ef6752d12f489c83edab577b86099 diff --git a/stream.go b/stream.go index 7d42020..39bfd5c 100644 --- a/stream.go +++ b/stream.go @@ -50,12 +50,10 @@ func NewDataStreamFromBytes(bytes []byte) (res DataStream) { func (self DataStream) free() { C.datastream_free(self.inner) } -func (self DataStream) AssignByCopy(src DataStream) { - C.datastream_assign_by_copy(self.inner, src.inner) -} - -func (self DataStream) AssignByMove(src DataStream) { - C.datastream_assign_by_move(self.inner, src.inner) +func (self DataStream) Copy() { + res := &dataStream{ inner: C.datastream_copy(self.inner, src.inner) } + runtime.SetFinalizer(res, func(self DataStream) { self.free() }) + return res } // TODO: datastream_data -- cgit v1.2.3-70-g09d2