mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor InfoSub to remove NetworkOPs dependency
This commit is contained in:
@@ -14,7 +14,6 @@ struct WSConnectionLog;
|
||||
// Helps with naming the lock
|
||||
struct WSConnectionBase
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template <typename endpoint_type>
|
||||
@@ -39,12 +38,10 @@ public:
|
||||
typedef typename endpoint_type::handler::message_ptr message_ptr;
|
||||
|
||||
public:
|
||||
// WSConnection()
|
||||
// : mHandler((WSServerHandler<websocketpp::WSDOOR_SERVER>*)(NULL)),
|
||||
// mConnection(connection_ptr()) { ; }
|
||||
|
||||
WSConnection (WSServerHandler<endpoint_type>* wshpHandler, const connection_ptr& cpConnection)
|
||||
: mRcvQueueLock (static_cast<WSConnectionBase const*>(this), "WSConn", __FILE__, __LINE__)
|
||||
WSConnection (InfoSub::Source& source, WSServerHandler<endpoint_type>* wshpHandler,
|
||||
const connection_ptr& cpConnection)
|
||||
: InfoSub (source)
|
||||
, mRcvQueueLock (static_cast<WSConnectionBase const*>(this), "WSConn", __FILE__, __LINE__)
|
||||
, mHandler (wshpHandler), mConnection (cpConnection), mNetwork (getApp().getOPs ()),
|
||||
mRemoteIP (cpConnection->get_socket ().lowest_layer ().remote_endpoint ().address ().to_string ()),
|
||||
mLoadSource (mRemoteIP), mPingTimer (cpConnection->get_io_service ()), mPinged (false),
|
||||
|
||||
@@ -25,9 +25,11 @@ SETUP_LOG (WSDoor)
|
||||
class WSDoorImp : public WSDoor, protected Thread, LeakChecked <WSDoorImp>
|
||||
{
|
||||
public:
|
||||
WSDoorImp (std::string const& strIp, int iPort, bool bPublic,
|
||||
WSDoorImp (InfoSub::Source& source,
|
||||
std::string const& strIp, int iPort, bool bPublic,
|
||||
boost::asio::ssl::context& ssl_context)
|
||||
: Thread ("websocket")
|
||||
, m_source (source)
|
||||
, m_ssl_context (ssl_context)
|
||||
, m_endpointLock (this, "WSDoor", __FILE__, __LINE__)
|
||||
, mPublic (bPublic)
|
||||
@@ -58,7 +60,7 @@ private:
|
||||
(mPublic ? "Public" : "Private") % mIp % mPort);
|
||||
|
||||
websocketpp::server_autotls::handler::ptr handler (
|
||||
new WSServerHandler <websocketpp::server_autotls> (
|
||||
new WSServerHandler <websocketpp::server_autotls> (m_source,
|
||||
m_ssl_context, mPublic));
|
||||
|
||||
{
|
||||
@@ -105,6 +107,7 @@ private:
|
||||
typedef RippleRecursiveMutex LockType;
|
||||
typedef LockType::ScopedLockType ScopedLockType;
|
||||
|
||||
InfoSub::Source& m_source;
|
||||
boost::asio::ssl::context& m_ssl_context;
|
||||
LockType m_endpointLock;
|
||||
|
||||
@@ -116,14 +119,14 @@ private:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
WSDoor* WSDoor::New (std::string const& strIp, int iPort, bool bPublic,
|
||||
boost::asio::ssl::context& ssl_context)
|
||||
WSDoor* WSDoor::New (InfoSub::Source& source, std::string const& strIp,
|
||||
int iPort, bool bPublic, boost::asio::ssl::context& ssl_context)
|
||||
{
|
||||
ScopedPointer <WSDoor> door;
|
||||
|
||||
try
|
||||
{
|
||||
door = new WSDoorImp (strIp, iPort, bPublic, ssl_context);
|
||||
door = new WSDoorImp (source, strIp, iPort, bPublic, ssl_context);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
class WSDoor
|
||||
{
|
||||
public:
|
||||
static WSDoor* New (std::string const& strIp, int iPort, bool bPublic,
|
||||
boost::asio::ssl::context& ssl_context);
|
||||
static WSDoor* New (InfoSub::Source& source, std::string const& strIp,
|
||||
int iPort, bool bPublic, boost::asio::ssl::context& ssl_context);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,11 @@ public:
|
||||
crTooSlow = 4000, // Client is too slow.
|
||||
};
|
||||
|
||||
private:
|
||||
InfoSub::Source& m_source;
|
||||
|
||||
protected:
|
||||
// VFALCO TODO Make this private.
|
||||
typedef RippleMutex LockType;
|
||||
typedef LockType::ScopedLockType ScopedLockType;
|
||||
LockType mLock;
|
||||
@@ -50,15 +54,15 @@ private:
|
||||
boost::asio::ssl::context& m_ssl_context;
|
||||
|
||||
protected:
|
||||
|
||||
// For each connection maintain an associated object to track subscriptions.
|
||||
boost::unordered_map <connection_ptr,
|
||||
boost::shared_ptr <WSConnection <endpoint_type> > > mMap;
|
||||
bool mPublic;
|
||||
|
||||
public:
|
||||
WSServerHandler (boost::asio::ssl::context& ssl_context, bool bPublic)
|
||||
: mLock (static_cast <WSServerHandlerBase*> (this), "WSServerHandler", __FILE__, __LINE__)
|
||||
WSServerHandler (InfoSub::Source& source, boost::asio::ssl::context& ssl_context, bool bPublic)
|
||||
: m_source (source)
|
||||
, mLock (static_cast <WSServerHandlerBase*> (this), "WSServerHandler", __FILE__, __LINE__)
|
||||
, m_ssl_context (ssl_context)
|
||||
, mPublic (bPublic)
|
||||
{
|
||||
@@ -168,7 +172,7 @@ public:
|
||||
|
||||
try
|
||||
{
|
||||
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> > (this, cpClient);
|
||||
mMap[cpClient] = boost::make_shared< WSConnection<endpoint_type> > (m_source, this, cpClient);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user