From efc7311893b0fb25129eb2b715992ba2ac43d65c Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Sun, 14 Oct 2018 06:05:09 +0200 Subject: Removed user from subscriptions on disconnect --- include/sibs/DirectConnection.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/sibs/DirectConnection.hpp') diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp index 4b5c67f..8e3865f 100644 --- a/include/sibs/DirectConnection.hpp +++ b/include/sibs/DirectConnection.hpp @@ -31,6 +31,7 @@ namespace sibs using PubSubConnectCallback = std::function peer, PubSubResult result, const std::string &resultStr)>; using PubSubReceiveDataCallback = std::function peer, const void *data, const usize size)>; using PubSubSendDataCallback = std::function; + using PubSubOnRemoveDisconnectedPeerCallback = std::function peer)>; struct DirectConnectionPeer { @@ -53,6 +54,8 @@ namespace sibs void connect(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc); void send(const std::shared_ptr peer, std::shared_ptr> data, PubSubSendDataCallback sendDataCallbackFunc = nullptr); + + void onRemoveDisconnectedPeer(PubSubOnRemoveDisconnectedPeerCallback callbackFunc); protected: int createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind = true); private: @@ -68,5 +71,6 @@ namespace sibs std::thread receiveDataThread; std::mutex peersMutex; bool alive; + PubSubOnRemoveDisconnectedPeerCallback removeDisconnectedPeerCallback; }; } -- cgit v1.2.3