RTFX  0.3
Real time special effects collaborative visualization and production library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
RTFXPeerSession.h
1 #ifndef __RTFX_PEERSESSION__
2 #define __RTFX_PEERSESSION__
3 
4 #pragma warning(disable: 4996)
5 
15 #include <boost/bind.hpp>
16 #include <boost/shared_ptr.hpp>
17 #include <boost/enable_shared_from_this.hpp>
18 #include <boost/asio.hpp>
19 
20 #include "RTFXParticipant.h"
21 #include "RTFXPeerPostOffice.h"
22 #include "RTFXDebug.h"
23 
24 using boost::asio::ip::tcp;
25 
26 namespace RTFX
27 {
28 
32  class RTFXAPI RTFXPeerSession : public RTFXParticipant, public boost::enable_shared_from_this<RTFXPeerSession>
33  {
34  public:
35 
37  RTFXPeerSession( boost::asio::io_service &_ioService, RTFXPeerPostOffice * _postOffice );
38 
40  ~RTFXPeerSession() { postOffice = NULL; }
41 
43  tcp::socket& Socket();
44 
46  void Start();
47 
49  void Deliver( const RTFXParcel &_parcel );
50 
52  void HandleReadHeader( const boost::system::error_code &_error );
53 
55  void HandleReadBody( const boost::system::error_code &_error );
56 
58  void HandleWrite( const boost:: system::error_code &_error );
59 
61  void SetOwnerID( boost::uuids::uuid _id )
62  {
63  ownerID = _id;
64  }
65 
67  boost::uuids::uuid GetOwnerID()
68  {
69  return ownerID;
70  }
71 
73  void SetP2P( bool _isP2P )
74  {
75  isP2P = _isP2P;
76  }
77 
79  bool GetP2P()
80  {
81  return isP2P;
82  }
83 
85  void SetPeer( void * _ptr )
86  {
87  peerPtr = _ptr;
88  }
89 
91  void * GetPeer()
92  {
93  return peerPtr;
94  }
95 
97  void SetHostname( string _hostname )
98  {
99  hostname = _hostname;
100  }
101 
103  string GetHostname()
104  {
105  return hostname;
106  }
107 
109  void DeleteHostname();
110 
112  bool IsSelf()
113  {
114  return isSelf;
115  }
116 
117  private:
118 
121  bool isSelf;
122 
125  string hostname;
126 
130  void * peerPtr;
131 
135  bool isP2P;
136 
140 
142  boost::uuids::uuid ownerID;
143 
145  tcp::socket socket;
146 
149 
152 
155 
158  };
159 }
160 
161 #endif