aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sibs/DirectConnection.hpp2
-rw-r--r--src/BootstrapNode.cpp9
-rw-r--r--src/DirectConnection.cpp2
3 files changed, 9 insertions, 4 deletions
diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp
index 900d419..0ac5724 100644
--- a/include/sibs/DirectConnection.hpp
+++ b/include/sibs/DirectConnection.hpp
@@ -51,7 +51,7 @@ namespace sibs
void connectServer(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc);
// Throws ConnectionException on error
void connect(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc);
- void send(const std::shared_ptr<DirectConnectionPeer> &peer, std::shared_ptr<std::vector<u8>> data, PubSubSendDataCallback sendDataCallbackFunc = nullptr);
+ void send(const std::shared_ptr<DirectConnectionPeer> peer, std::shared_ptr<std::vector<u8>> data, PubSubSendDataCallback sendDataCallbackFunc = nullptr);
protected:
int createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind = true);
private:
diff --git a/src/BootstrapNode.cpp b/src/BootstrapNode.cpp
index f7fe738..9edf008 100644
--- a/src/BootstrapNode.cpp
+++ b/src/BootstrapNode.cpp
@@ -88,16 +88,21 @@ namespace sibs
serializer.add((u16)newPeer->address.address.sin_port);
std::shared_ptr<std::vector<u8>> serializerData = std::make_shared<std::vector<u8>>(std::move(serializer.getBuffer()));
+ auto sendCallbackFunc = [](PubSubResult result, const std::string &resultStr)
+ {
+ Log::debug("BootstrapNode::peerSubscribe send result: %d, result string: %s", result, resultStr.c_str());
+ };
+
sibs::SafeSerializer newPeerSerializer;
newPeerSerializer.add(pubsubKey.data.data(), pubsubKey.data.size());
for(auto &peer : peers)
{
- connections.send(peer, serializerData);
+ connections.send(peer, serializerData, sendCallbackFunc);
newPeerSerializer.add((u32)peer->address.address.sin_family);
newPeerSerializer.add((u32)peer->address.address.sin_addr.s_addr);
newPeerSerializer.add((u16)peer->address.address.sin_port);
}
peers.push_back(newPeer);
- connections.send(newPeer, std::make_shared<std::vector<u8>>(std::move(newPeerSerializer.getBuffer())));
+ connections.send(newPeer, std::make_shared<std::vector<u8>>(std::move(newPeerSerializer.getBuffer())), sendCallbackFunc);
}
}
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp
index 03fc27c..3108410 100644
--- a/src/DirectConnection.cpp
+++ b/src/DirectConnection.cpp
@@ -121,7 +121,7 @@ namespace sibs
}).detach();
}
- void DirectConnections::send(const std::shared_ptr<DirectConnectionPeer> &peer, std::shared_ptr<std::vector<u8>> data, PubSubSendDataCallback sendDataCallbackFunc)
+ void DirectConnections::send(const std::shared_ptr<DirectConnectionPeer> peer, std::shared_ptr<std::vector<u8>> data, PubSubSendDataCallback sendDataCallbackFunc)
{
// TODO: Replace this with light-weight threads (fibers)?
std::thread([peer, data, sendDataCallbackFunc]()