reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ConnectionManager.cxx
Go to the documentation of this file.
1#include <algorithm>
2#include <functional>
3
5#include "TurnManager.hxx"
6
7namespace reTurn {
8
9void
11{
12 if(!mTurnManager.addConnection(remoteAddress))
13 {
14 c->stop();
15 return;
16 }
17 mConnections[c] = remoteAddress;
18 c->start();
19}
20
21void
23{
24 std::map<ConnectionPtr, asio::ip::address>::iterator it = mConnections.find(c);
25 if(it != mConnections.end())
26 {
27 mTurnManager.removeConnection(it->second);
28 mConnections.erase(it);
29 }
30 c->stop();
31}
32
33void
35{
36 std::map<ConnectionPtr, asio::ip::address>::iterator it = mConnections.begin();
37
38 for(; it != mConnections.end(); it++)
39 {
40 mTurnManager.removeConnection(it->second);
41 it->first->stop();
42 }
43 mConnections.clear();
44}
45
46}
47
48
49/* ====================================================================
50
51 Copyright (c) 2008-2026 SIP Spectrum, Inc. https://www.sipspectrum.com
52 Copyright (c) 2007-2008, Plantronics, Inc.
53 All rights reserved.
54
55 Redistribution and use in source and binary forms, with or without
56 modification, are permitted provided that the following conditions are
57 met:
58
59 1. Redistributions of source code must retain the above copyright
60 notice, this list of conditions and the following disclaimer.
61
62 2. Redistributions in binary form must reproduce the above copyright
63 notice, this list of conditions and the following disclaimer in the
64 documentation and/or other materials provided with the distribution.
65
66 3. Neither the name of Plantronics nor the names of its contributors
67 may be used to endorse or promote products derived from this
68 software without specific prior written permission.
69
70 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
74 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81
82 ==================================================================== */
void stop(ConnectionPtr c)
Stop the specified connection.
void stopAll()
Stop all connections.
void start(ConnectionPtr c, const asio::ip::address &remoteAddress)
Add the specified connection, from remoteAddress, to the manager and start it - or,...
void removeConnection(const asio::ip::address &address)
bool addConnection(const asio::ip::address &address)
TCP and TLS connections per client IP address (MaxTcpConnectionsPerIp): addConnection returns false,...
std::shared_ptr< AsyncSocketBase > ConnectionPtr
void list()
Definition userAdmin.cxx:66