@@ -195,3 +195,43 @@ polymorph::network::SessionStore::SessionStore(const polymorph::network::Session
195195{
196196
197197}
198+
199+ void polymorph::network::SessionStore::copyTcpSessionsFrom (polymorph::network::SessionStore &other)
200+ {
201+ std::lock_guard<std::mutex> lock (_tcpSessionsMutex);
202+ std::lock_guard<std::mutex> lock2 (other._tcpSessionsMutex );
203+
204+ std::copy_if (other._tcpSessions .begin (), other._tcpSessions .end (), std::inserter (_tcpSessions, _tcpSessions.end ()), [this ](auto &pair) {
205+ return !_tcpSessions.contains (pair.first );
206+ });
207+ }
208+
209+ void polymorph::network::SessionStore::copyUdpSessionsFrom (polymorph::network::SessionStore &other)
210+ {
211+ std::lock_guard<std::mutex> lock (_udpSessionsMutex);
212+ std::lock_guard<std::mutex> lock2 (other._udpSessionsMutex );
213+
214+ std::copy_if (other._udpSessions .begin (), other._udpSessions .end (), std::inserter (_udpSessions, _udpSessions.end ()), [this ](auto &pair) {
215+ return !_udpSessions.contains (pair.first );
216+ });
217+ }
218+
219+ void polymorph::network::SessionStore::copyTcpAuthorizationKeysFrom (polymorph::network::SessionStore &other)
220+ {
221+ std::lock_guard<std::mutex> lock (_tcpSessionsAuthorizationKeysMutex);
222+ std::lock_guard<std::mutex> lock2 (other._tcpSessionsAuthorizationKeysMutex );
223+
224+ std::copy_if (other._tcpSessionsAuthorizationKeys .begin (), other._tcpSessionsAuthorizationKeys .end (), std::inserter (_tcpSessionsAuthorizationKeys, _tcpSessionsAuthorizationKeys.end ()), [this ](auto &pair) {
225+ return !_tcpSessionsAuthorizationKeys.contains (pair.first );
226+ });
227+ }
228+
229+ void polymorph::network::SessionStore::copyUdpAuthorizationKeysFrom (polymorph::network::SessionStore &other)
230+ {
231+ std::lock_guard<std::mutex> lock (_udpSessionsAuthorizationKeysMutex);
232+ std::lock_guard<std::mutex> lock2 (other._udpSessionsAuthorizationKeysMutex );
233+
234+ std::copy_if (other._udpSessionsAuthorizationKeys .begin (), other._udpSessionsAuthorizationKeys .end (), std::inserter (_udpSessionsAuthorizationKeys, _udpSessionsAuthorizationKeys.end ()), [this ](auto &pair) {
235+ return !_udpSessionsAuthorizationKeys.contains (pair.first );
236+ });
237+ }
0 commit comments