diff options
-rw-r--r-- | include/salticidae/network.h | 7 | ||||
-rw-r--r-- | src/network.cpp | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/include/salticidae/network.h b/include/salticidae/network.h index f8b3353..bece509 100644 --- a/include/salticidae/network.h +++ b/include/salticidae/network.h @@ -1266,8 +1266,11 @@ void peernetwork_send_msg_deferred_by_move(peernetwork_t *self, msg_t * _moved_m void peernetwork_multicast_msg_by_move(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *addrs); void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, SalticidaeCError *err); -typedef void (*msgnetwork_unknown_peer_callback_t)(const netaddr_t *, void *userdata); -void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, msgnetwork_unknown_peer_callback_t cb, void *userdata); +typedef void (*peernetwork_peer_callback_t)(const peernetwork_conn_t *, bool connected, void *userdata); +void peernetwork_reg_peer_handler(peernetwork_t *self, peernetwork_peer_callback_t cb, void *userdata); + +typedef void (*peernetwork_unknown_peer_callback_t)(const netaddr_t *, void *userdata); +void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, peernetwork_unknown_peer_callback_t cb, void *userdata); /* ClientNetwork */ diff --git a/src/network.cpp b/src/network.cpp index 2dc7d1f..adcac99 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -251,8 +251,16 @@ void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, Salti SALTICIDAE_CERROR_CATCH(cerror) } +void peernetwork_reg_peer_handler(peernetwork_t *self, + peernetwork_peer_callback_t cb, + void *userdata) { + self->reg_peer_handler([=](const peernetwork_conn_t &conn, bool connected) { + cb(&conn, connected, userdata); + }); +} + void peernetwork_reg_unknown_peer_handler(peernetwork_t *self, - msgnetwork_unknown_peer_callback_t cb, + peernetwork_unknown_peer_callback_t cb, void *userdata) { self->reg_unknown_peer_handler([=](const NetAddr &claimed_addr) { cb(&claimed_addr, userdata); |