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

Contents of /main/reTurn/TcpConnection.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11159 - (show annotations) (download)
Fri Apr 25 14:03:32 2014 UTC (5 years, 6 months ago) by sgodin
File MIME type: text/plain
File size: 3598 byte(s)
-modified asio and boost include file ordering to avoid multiply defined symbol errors on linking
 -in preparation for upgrade of asio drop and support for latest boost 
 -include asio/ssh.hpp everywhere asio.hpp is included
 -include boost headers before others, to ensure we are not redefining stdint definitions in some includes
  and not others

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

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