25 #include "RTFXPeerPostOffice.h"
26 #include "RTFXPeerSession.h"
32 typedef boost::shared_ptr<RTFXPeerSession> RTFXPeerSessionPtr;
48 void Start(
string _hostname,
string _connectionHostname,
unsigned int _port = 0 );
54 void ConnectToPeer(
string _hostname );
57 void ConnectToPeer( boost::asio::io_service &_ioService, tcp::resolver::iterator &_endpointIterator );
60 void DisconnectFromPeers();
66 void StartAccepting();
69 void HandleAccept( RTFXPeerSessionPtr _session,
const boost::system::error_code &_error );
81 void Send(
string &_data,
bool _isDataRTFX );
87 bool CheckForUpdates();
90 void SetServerKeepData(
bool _keepData )
92 keepDataAtServer = _keepData;
96 bool GetServerKeepData()
98 return keepDataAtServer;
102 void SetHostname(
string _hostname )
104 hostname = _hostname;
114 void AddHostname(
string _hostname )
116 debug( ostringstream().flush() <<
"RTFXPeer::AddHostname: adding hostname " << _hostname << endl );
117 if ( connectionList.find( _hostname ) == connectionList.end() )
118 connectionList[ _hostname ] = 1;
120 connectionList[ _hostname ] = connectionList[ _hostname ] + 1;
124 void DeleteHostname(
string _hostname )
126 debug( ostringstream().flush() <<
"RTFXPeer::DeleteHostname: deleting hostname " << _hostname << endl );
128 if ( connectionList.find( _hostname ) != connectionList.end() )
129 connectionList[ _hostname ] --;
133 void SetConnectionHostname(
string _chostname )
135 connectionHostname = _chostname;
139 string GetConnectionHostname()
141 return connectionHostname;
145 string GetHostnameData()
147 string hostnameData_ =
"";
148 stringstream ss_( stringstream::in | stringstream:: out );
150 map<string, int>::iterator iter_ = connectionList.begin();
151 while ( iter_ != connectionList.end() )
153 ss_ << (*iter_).first <<
"," << (*iter_).second <<
"\n";
157 hostnameData_ = ss_.str();
158 return hostnameData_;
162 bool HasNewDataArrived()
164 return isNewDataAvailable;
168 void SetNewDataArrived(
bool _value )
170 isNewDataAvailable = _value;
174 void DeleteObjectEverywhere(
RTFXObject * _obj );
177 bool IsCustomDataAvailable()
179 if ( mailbox->GetCustomDataCount() > 0 )
return true;
186 compressionType = _tmp;
187 mailbox->SetDefaultCompressionType( _tmp );
188 postOffice.SetDefaultCompressionType( _tmp );
195 void SetArchiveType(
bool _isBinaryData )
197 isBinaryData = _isBinaryData;
201 bool GetArchiveType()
209 void StartServer(
unsigned int _port );
212 void ConnectToPeer(
string _connectionHostname,
string _port );
215 int CountKnownConnections()
217 map<string, int>::iterator iter_ = connectionList.begin();
220 while ( iter_ != connectionList.end() )
222 count_ += (*iter_).second;
229 void ResetKnownConnections()
231 connectionList.clear();
233 map<string,int> tmp_;
234 tmp_.swap( connectionList );
241 boost::thread * clientThread;
256 void PeerHandleReadHeader(
const boost::system::error_code &_error );
275 void PeerHandleConnect(
const boost::system::error_code &_error, tcp::resolver::iterator _endpointIterator );
278 void PeerHandleReadBody(
const boost::system::error_code &_error );
284 void PeerHandleWrite(
const boost::system::error_code &_error );
321 boost::uuids::uuid
id;