/[resiprocate]/main/reTurn/TlsConnection.hxx
ViewVC logotype

Contents of /main/reTurn/TlsConnection.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10481 - (show annotations) (download)
Thu Sep 12 07:59:36 2013 UTC (6 years, 2 months ago) by dpocock
File MIME type: text/plain
File size: 3732 byte(s)
reTurn: revert commits 10472 and 10473, now on branch b-reTurn-async
1 #ifndef TLS_CONNECTION_HXX
2 #define TLS_CONNECTION_HXX
3
4 #include <asio.hpp>
5 #include <asio/ssl.hpp>
6 #include <boost/array.hpp>
7 #include <boost/noncopyable.hpp>
8 #include "RequestHandler.hxx"
9 #include "AsyncTlsSocketBase.hxx"
10
11 namespace reTurn {
12
13 class ConnectionManager;
14
15 typedef asio::ssl::stream<asio::ip::tcp::socket> ssl_socket;
16
17 /// Represents a single connection from a client.
18 class TlsConnection
19 : public AsyncTlsSocketBase,
20 private boost::noncopyable
21 {
22 public:
23 /// Construct a connection with the given io_service.
24 explicit TlsConnection(asio::io_service& ioService, ConnectionManager& manager, RequestHandler& handler, asio::ssl::context& context);
25 ~TlsConnection();
26
27 /// Get the socket associated with the connection.
28 ssl_socket::lowest_layer_type& socket();
29
30 /// Start the first asynchronous operation for the connection.
31 virtual void start();
32
33 /// Override close fn in AsyncTcpSocketBase so that we can remove ourselves from connection manager
34 virtual void close();
35
36 /// Stop all asynchronous operations associated with the connection.
37 virtual void stop();
38
39 protected:
40 /// Handle completion of a handshake operation
41 virtual void onServerHandshakeSuccess();
42 virtual void onServerHandshakeFailure(const asio::error_code& e);
43
44 /// Handle completion of a receive operation
45 virtual void onReceiveSuccess(const asio::ip::address& address, unsigned short port, boost::shared_ptr<DataBuffer>& data);
46 virtual void onReceiveFailure(const asio::error_code& e);
47
48 /// Handle completion of a send operation
49 virtual void onSendSuccess();
50 virtual void onSendFailure(const asio::error_code& e);
51
52 /// The manager for this connection.
53 ConnectionManager& mConnectionManager;
54
55 /// Manages turn allocations
56 TurnAllocationManager mTurnAllocationManager;
57
58 /// The handler used to process the incoming request.
59 RequestHandler& mRequestHandler;
60
61 // Stores the local address and port
62 asio::ip::address mLocalAddress;
63 unsigned short mLocalPort;
64
65 private:
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 ==================================================================== */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27