reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TcpConnection.hxx
Go to the documentation of this file.
1#ifndef TCP_CONNECTION_HXX
2#define TCP_CONNECTION_HXX
3
4#include <asio.hpp>
5#ifdef USE_SSL
6#include <asio/ssl.hpp>
7#endif
8#include "RequestHandler.hxx"
9#include "StunTuple.hxx"
12
13namespace reTurn {
14
15class ConnectionManager;
16
19 : public AsyncTcpSocketBase
20{
21public:
23 explicit TcpConnection(asio::io_context& ioService, ConnectionManager& manager, RequestHandler& handler);
24 TcpConnection(const TcpConnection&) = delete;
27
30
32 asio::ip::tcp::socket& socket();
33
35 virtual void start();
36
38 virtual void close();
39
41 virtual void stop();
42
43protected:
45 virtual void onReceiveSuccess(const asio::ip::address& address, unsigned short port, const std::shared_ptr<DataBuffer>& data);
46 virtual void onReceiveFailure(const asio::error_code& e);
47
49 virtual void onSendSuccess();
50 virtual void onSendFailure(const asio::error_code& e);
51
54
57
60
61 // Stores the local address and port
62 asio::ip::address mLocalAddress;
63 unsigned short mLocalPort;
64
65private:
66};
67
68}
69
70#endif
71
72
73/* ====================================================================
74
75 Copyright (c) 2007-2008, Plantronics, Inc.
76 All rights reserved.
77
78 Redistribution and use in source and binary forms, with or without
79 modification, are permitted provided that the following conditions are
80 met:
81
82 1. Redistributions of source code must retain the above copyright
83 notice, this list of conditions and the following disclaimer.
84
85 2. Redistributions in binary form must reproduce the above copyright
86 notice, this list of conditions and the following disclaimer in the
87 documentation and/or other materials provided with the distribution.
88
89 3. Neither the name of Plantronics nor the names of its contributors
90 may be used to endorse or promote products derived from this
91 software without specific prior written permission.
92
93 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
94 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
95 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
96 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
97 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
98 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
99 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
100 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
101 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
102 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
103 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104
105 ==================================================================== */
Manages open connections so that they may be cleanly stopped when the server needs to shut down,...
The common handler for all incoming requests.
Represents a single connection from a client.
virtual void stop()
Stop all asynchronous operations associated with the connection.
RequestHandler & mRequestHandler
The handler used to process the incoming request.
virtual void onSendFailure(const asio::error_code &e)
TcpConnection & operator=(TcpConnection &&)=delete
asio::ip::tcp::socket & socket()
Get the socket associated with the connection.
TcpConnection & operator=(const TcpConnection &)=delete
virtual void close()
Override close fn in AsyncTcpSocketBase so that we can remove ourselves from connection manager.
asio::ip::address mLocalAddress
TcpConnection(TcpConnection &&)=delete
TcpConnection(const TcpConnection &)=delete
virtual void onReceiveSuccess(const asio::ip::address &address, unsigned short port, const std::shared_ptr< DataBuffer > &data)
Handle completion of a receive operation.
unsigned short mLocalPort
virtual void start()
Start the first asynchronous operation for the connection.
virtual void onReceiveFailure(const asio::error_code &e)
virtual void onSendSuccess()
Handle completion of a send operation.
TurnAllocationManager mTurnAllocationManager
Manages turn allocations.
ConnectionManager & mConnectionManager
The connection manager for this connection.
void list()
Definition userAdmin.cxx:66