Sirikata
|
ObjectHostConnectionManager handles the networking aspects of interacting with object hosts. More...
#include <ObjectHostConnectionManager.hpp>
ObjectHostConnectionManager handles the networking aspects of interacting with object hosts.
It listens for connections, maintains per object connections, and handles shipping messages out to the network.
typedef std::set<ObjectHostConnection*> Sirikata::ObjectHostConnectionManager::ObjectHostConnectionSet [private] |
typedef std::tr1::unordered_map<ShortObjectHostConnectionID, ObjectHostConnection*> Sirikata::ObjectHostConnectionManager::ShortIDConnectionMap [private] |
Sirikata::ObjectHostConnectionManager::ObjectHostConnectionManager | ( | SpaceContext * | ctx, |
const Address4 & | listen_addr, | ||
OHDP::Service * | ohdp_service, | ||
Listener * | listener | ||
) |
References Sirikata::SST::ConnectionManager< EndPointType >::createDatagramLayer(), Sirikata::SST::ConnectionManager< EndPointType >::listen(), listen(), mContext, mListener, mOHSSTDatagramLayer, newOHStream(), Sirikata::SpaceID::null(), OBJECT_SPACE_PORT, Sirikata::SpaceContext::ohSSTConnectionManager(), and Sirikata::OHDP::NodeID::self().
Sirikata::ObjectHostConnectionManager::~ObjectHostConnectionManager | ( | ) |
void Sirikata::ObjectHostConnectionManager::closeAllConnections | ( | ) | [private] |
References destroyConnection(), and mConnections.
Referenced by shutdown().
ObjectHostConnectionID Sirikata::ObjectHostConnectionManager::conn_id | ( | ObjectHostConnection * | c | ) | [static, private] |
Referenced by destroyConnection(), handleConnectionRead(), and newOHStream().
void Sirikata::ObjectHostConnectionManager::destroyConnection | ( | ObjectHostConnection * | conn | ) | [private] |
void Sirikata::ObjectHostConnectionManager::handleConnectionEvent | ( | ObjectHostConnection * | conn, |
Sirikata::Network::Stream::ConnectionStatus | status, | ||
const std::string & | reason | ||
) | [private] |
Reading and writing handling for ObjectHostConnections.
References destroyConnection(), Sirikata::Network::Stream::Disconnected, Sirikata::Context::mainStrand, mContext, and Sirikata::Network::IOStrand::post().
Referenced by handleNewConnection().
void Sirikata::ObjectHostConnectionManager::handleConnectionRead | ( | ObjectHostConnection * | conn, |
Sirikata::Network::Chunk & | chunk, | ||
const Sirikata::Network::Stream::PauseReceiveCallback & | pause | ||
) | [private] |
References conn_id(), Sirikata::Logging::error, Sirikata::Trace::HANDLE_OBJECT_HOST_MESSAGE, Sirikata::Logging::insane, LOG_INVALID_MESSAGE, mListener, Sirikata::ObjectHostConnectionManager::Listener::onObjectHostMessageReceived(), Sirikata::ObjectHostConnection::short_id, SPACE_LOG, and TIMESTAMP.
Referenced by handleNewConnection().
void Sirikata::ObjectHostConnectionManager::handleNewConnection | ( | Sirikata::Network::Stream * | str, |
Sirikata::Network::Stream::SetCallbacks & | sc | ||
) | [private] |
void Sirikata::ObjectHostConnectionManager::insertConnection | ( | ObjectHostConnection * | conn | ) | [private] |
References mConnections, mShortConnections, and Sirikata::ObjectHostConnection::short_id.
Referenced by handleNewConnection().
void Sirikata::ObjectHostConnectionManager::listen | ( | const Address4 & | listen_addr | ) | [private] |
Listen for and handle new connections.
References Sirikata::convertAddress4ToSirikata(), Sirikata::Logging::debug, Sirikata::FactoryWithOptionsImpl< T, Ftype >::getConstructor(), Sirikata::FactoryWithOptionsImpl< T, Ftype >::getOptionParser(), Sirikata::GetOptionValue< String >(), Sirikata::Network::StreamListenerFactory::getSingleton(), handleNewConnection(), Sirikata::Network::StreamListener::listen(), mAcceptor, mIOStrand, SPACE_LOG, and Sirikata::JS::JSPresence::toString().
Referenced by ObjectHostConnectionManager().
Network::IOStrand* const Sirikata::ObjectHostConnectionManager::netStrand | ( | ) | const [inline] |
void Sirikata::ObjectHostConnectionManager::newOHStream | ( | int | err, |
OHDPSST::Stream::Ptr | s | ||
) | [private] |
bool Sirikata::ObjectHostConnectionManager::send | ( | const ShortObjectHostConnectionID | short_conn_id, |
Sirikata::Protocol::Object::ObjectMessage * | msg | ||
) |
bool Sirikata::ObjectHostConnectionManager::send | ( | const ObjectHostConnectionID & | conn_id, |
Sirikata::Protocol::Object::ObjectMessage * | msg | ||
) |
NOTE: Must be used from within the main strand.
Currently this is required since we have the return value...
References Sirikata::ObjectHostConnectionID::conn, Sirikata::Logging::error, Sirikata::Logging::fatal, mConnections, mContext, sendHelper(), SPACE_LOG, and Sirikata::Context::stopped().
Referenced by Sirikata::Server::delegateOHDPPortSend(), Sirikata::ObjectConnection::send(), and Sirikata::Server::sendSessionMessageWithRetry().
bool Sirikata::ObjectHostConnectionManager::sendHelper | ( | ObjectHostConnection * | conn, |
Sirikata::Protocol::Object::ObjectMessage * | msg | ||
) | [private] |
void Sirikata::ObjectHostConnectionManager::shutdown | ( | ) |
References Sirikata::Network::StreamListener::close(), closeAllConnections(), mAcceptor, Sirikata::Context::mainStrand, mContext, and Sirikata::Network::IOStrand::post().
Referenced by Sirikata::Server::stop().
bool Sirikata::ObjectHostConnectionManager::validConnection | ( | const ObjectHostConnectionID & | conn_id | ) | const |
References Sirikata::ObjectHostConnectionID::conn, mConnections, mContext, and Sirikata::Context::stopped().
Referenced by Sirikata::Server::sendSessionMessageWithRetry().
bool Sirikata::ObjectHostConnectionManager::validConnection | ( | const ShortObjectHostConnectionID & | short_conn_id | ) | const |
References mContext, mShortConnections, and Sirikata::Context::stopped().
Referenced by listen(), shutdown(), and ~ObjectHostConnectionManager().
Referenced by closeAllConnections(), destroyConnection(), insertConnection(), send(), and validConnection().
Referenced by handleConnectionEvent(), handleNewConnection(), ObjectHostConnectionManager(), send(), shutdown(), and validConnection().
Referenced by listen(), and ~ObjectHostConnectionManager().
Referenced by destroyConnection(), handleConnectionRead(), newOHStream(), and ObjectHostConnectionManager().
OHDPSST::BaseDatagramLayer::Ptr Sirikata::ObjectHostConnectionManager::mOHSSTDatagramLayer [private] |
Referenced by ObjectHostConnectionManager().
Referenced by destroyConnection(), insertConnection(), newOHStream(), send(), and validConnection().
Referenced by handleNewConnection().