aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-21 14:36:06 -0400
committerDeterminant <[email protected]>2019-06-21 14:36:06 -0400
commitff904b23147e72db4f7f77f8269242d9a5a0859e (patch)
tree2ddf080f917e8138911185f0abba496a866dc240
parent823585c4db2ef6752d12f489c83edab577b86099 (diff)
...
-rw-r--r--include/salticidae/network.h6
-rw-r--r--src/network.cpp22
-rw-r--r--test/test_msgnet_c.c4
3 files changed, 20 insertions, 12 deletions
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index b703c35..3687c7e 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -984,7 +984,8 @@ void msgnetwork_config_queue_capacity(msgnetwork_config_t *self, size_t cap);
msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t *config);
void msgnetwork_free(const msgnetwork_t *self);
-void msgnetwork_send_msg_by_move(msgnetwork_t *self, msg_t *_moved_msg, const msgnetwork_conn_t *conn);
+void msgnetwork_send_msg(msgnetwork_t *self, const msg_t *msg, const msgnetwork_conn_t *conn);
+void msgnetwork_send_msg_deferred_by_move(msgnetwork_t *self, msg_t *_moved_msg, const msgnetwork_conn_t *conn);
msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr, SalticidaeCError *err);
msgnetwork_conn_t *msgnetwork_conn_copy(const msgnetwork_conn_t *self);
void msgnetwork_conn_free(const msgnetwork_conn_t *self);
@@ -1029,7 +1030,8 @@ msgnetwork_conn_t *msgnetwork_conn_new_from_peernetwork_conn(const peernetwork_c
peernetwork_conn_t *peernetwork_conn_new_from_msgnetwork_conn_unsafe(const msgnetwork_conn_t *conn);
peernetwork_conn_t *peernetwork_conn_copy(const peernetwork_conn_t *self);
void peernetwork_conn_free(const peernetwork_conn_t *self);
-void peernetwork_send_msg_by_move(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *paddr);
+void peernetwork_send_msg(peernetwork_t *self, const msg_t * msg, const netaddr_t *paddr);
+void peernetwork_send_msg_deferred_by_move(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *paddr);
void peernetwork_multicast_msg_by_move(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *paddrs);
void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, SalticidaeCError *err);
void peernetwork_stop(peernetwork_t *self);
diff --git a/src/network.cpp b/src/network.cpp
index 4067531..122270b 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -44,10 +44,13 @@ void msgnetwork_config_queue_capacity(msgnetwork_config_t *self, size_t cap) {
self->queue_capacity(cap);
}
-void msgnetwork_send_msg_by_move(msgnetwork_t *self,
+void msgnetwork_send_msg(msgnetwork_t *self, const msg_t *msg, const msgnetwork_conn_t *conn) {
+ self->_send_msg(*msg, *conn);
+}
+
+void msgnetwork_send_msg_deferred_by_move(msgnetwork_t *self,
msg_t *_moved_msg, const msgnetwork_conn_t *conn) {
self->_send_msg_deferred(std::move(*_moved_msg), *conn);
- //delete _moved_msg;
}
msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr, SalticidaeCError *cerror) {
@@ -211,17 +214,20 @@ peernetwork_conn_t *peernetwork_conn_copy(const peernetwork_conn_t *self) {
void peernetwork_conn_free(const peernetwork_conn_t *self) { delete self; }
-void peernetwork_send_msg_by_move(peernetwork_t *self,
- msg_t * _moved_msg, const netaddr_t *paddr) {
+void peernetwork_send_msg(peernetwork_t *self,
+ const msg_t * msg, const netaddr_t *paddr) {
+ self->_send_msg(*msg, *paddr);
+}
+
+void peernetwork_send_msg_deferred_by_move(peernetwork_t *self,
+ msg_t * _moved_msg, const netaddr_t *paddr) {
self->_send_msg_deferred(std::move(*_moved_msg), *paddr);
- //delete _moved_msg;
}
void peernetwork_multicast_msg_by_move(peernetwork_t *self,
- msg_t *_moved_msg,
- const netaddr_array_t *paddrs) {
+ msg_t *_moved_msg,
+ const netaddr_array_t *paddrs) {
self->_multicast_msg(std::move(*_moved_msg), *paddrs);
- //delete _moved_msg;
}
void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, SalticidaeCError *cerror) {
diff --git a/test/test_msgnet_c.c b/test/test_msgnet_c.c
index f99c88b..aeedd99 100644
--- a/test/test_msgnet_c.c
+++ b/test/test_msgnet_c.c
@@ -108,7 +108,7 @@ void on_receive_hello(const msg_t *_msg, const msgnetwork_conn_t *conn, void *us
free(msg.text);
msg_t *ack = msg_ack_serialize();
/* send acknowledgement */
- msgnetwork_send_msg_by_move(net, ack, conn);
+ msgnetwork_send_msg(net, ack, conn);
msg_free(ack);
}
@@ -128,7 +128,7 @@ bool conn_handler(const msgnetwork_conn_t *conn, bool connected, void *userdata)
printf("[%s] Connected, sending hello.\n", name);
/* send the first message through this connection */
msg_t *hello = msg_hello_serialize(name, "Hello there!");
- msgnetwork_send_msg_by_move(n->net, hello, conn);
+ msgnetwork_send_msg(n->net, hello, conn);
msg_free(hello);
}
else