Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::remote::RemoteServer Class Reference

A RemoteServer starts an HttpServer with a predefined handler for the /ion subdirectory. More...

#include "remoteserver.h"

Inheritance diagram for ion::remote::RemoteServer:
Collaboration diagram for ion::remote::RemoteServer:

Public Types

typedef std::map< std::string,
std::string > 
QueryMap
 
typedef std::map< void
*, WebsocketHelper * > 
WebsocketMap
 
typedef base::ReferentPtr
< Websocket >::Type 
WebsocketPtr
 
typedef base::ReferentPtr
< RequestHandler >::Type 
RequestHandlerPtr
 
typedef std::map< std::string,
RequestHandlerPtr
HandlerMap
 

Public Member Functions

 RemoteServer (int port)
 Starts a RemoteServer on the passed port. More...
 
 RemoteServer (const gfx::RendererPtr &renderer, const gfxutils::ShaderManagerPtr &shader_manager, const gfxutils::FramePtr &frame, int port)
 Starts a RemoteServer and takes shared ownership of some key Ion objects of the application. More...
 
 ~RemoteServer () override
 
void AddNode (const gfx::NodePtr &node) const
 Adds a Node to the NodeGraphHandler which allows Remote to inspect it in the web interface. More...
 
bool RemoveNode (const gfx::NodePtr &node) const
 Removes a Node from the NodeGraphHandler. More...
 
const std::string GetUriData (const std::string &uri) const
 Returns the data of the requested URI, or returns an empty string if it does not exist. More...
 
bool IsRunning () const
 Returns whether the server is running. More...
 
void RegisterHandler (const RequestHandlerPtr &handler)
 Registers the passed handler at the path returned by handler->GetBasePath(). More...
 
void UnregisterHandler (const std::string &path)
 Unregisters the handler at path. More...
 
HandlerMap GetHandlers () const
 Returns the handlers registered with this server. More...
 
bool EmbedLocalSourcedFiles () const
 Gets, sets whether local sourced files (tags with src=... More...
 
void SetEmbedLocalSourcedFiles (bool embed)
 
size_t WebsocketCount ()
 Return the number of currently-connected websockets. More...
 
const std::string & GetFooterHtml () const
 Sets/gets the header and footer HTML, which are both empty by default. More...
 
const std::string & GetHeaderHtml () const
 
void SetFooterHtml (const std::string &str)
 
void SetHeaderHtml (const std::string &str)
 

Detailed Description

A RemoteServer starts an HttpServer with a predefined handler for the /ion subdirectory.

Definition at line 37 of file remoteserver.h.

Member Typedef Documentation

typedef std::map<std::string, RequestHandlerPtr> ion::remote::HttpServer::HandlerMap
inherited

Definition at line 116 of file httpserver.h.

typedef std::map<std::string, std::string> ion::remote::HttpServer::QueryMap
inherited

Definition at line 35 of file httpserver.h.

Definition at line 115 of file httpserver.h.

typedef std::map<void*, WebsocketHelper*> ion::remote::HttpServer::WebsocketMap
inherited

Definition at line 38 of file httpserver.h.

Definition at line 65 of file httpserver.h.

Constructor & Destructor Documentation

ion::remote::RemoteServer::RemoteServer ( int  port)
explicit

Starts a RemoteServer on the passed port.

Definition at line 112 of file remoteserver.cc.

ion::remote::RemoteServer::RemoteServer ( const gfx::RendererPtr renderer,
const gfxutils::ShaderManagerPtr shader_manager,
const gfxutils::FramePtr frame,
int  port 
)

Starts a RemoteServer and takes shared ownership of some key Ion objects of the application.

It instantiates all Ion handlers.

Definition at line 117 of file remoteserver.cc.

References ion::remote::HttpServer::RegisterHandler(), and ion::base::SharedPtr< T >::Reset().

ion::remote::RemoteServer::~RemoteServer ( )
override

Definition at line 199 of file remoteserver.cc.

Member Function Documentation

void ion::remote::RemoteServer::AddNode ( const gfx::NodePtr node) const

Adds a Node to the NodeGraphHandler which allows Remote to inspect it in the web interface.

Note that this only happens if there is a NodeGraphHandler added to Remote.

Definition at line 176 of file remoteserver.cc.

References ion::remote::HttpServer::GetHandlers().

bool ion::remote::HttpServer::EmbedLocalSourcedFiles ( ) const
inlineinherited

Gets, sets whether local sourced files (tags with src=...

such as img and script that reference files starting with '/') should be embedded in returned HTML pages.

Definition at line 144 of file httpserver.h.

const std::string& ion::remote::HttpServer::GetFooterHtml ( ) const
inlineinherited

Sets/gets the header and footer HTML, which are both empty by default.

When RequestHandlers return HTML pages, the special string is replaced by the header HTML, while is replaced by the footer HTML.

Definition at line 156 of file httpserver.h.

HttpServer::HandlerMap ion::remote::HttpServer::GetHandlers ( ) const
inherited

Returns the handlers registered with this server.

Definition at line 729 of file httpserver.cc.

Referenced by AddNode(), ion::remote::HttpServer::GetUriData(), and RemoveNode().

const std::string& ion::remote::HttpServer::GetHeaderHtml ( ) const
inlineinherited

Definition at line 157 of file httpserver.h.

const std::string ion::remote::HttpServer::GetUriData ( const std::string &  uri) const
inherited

Returns the data of the requested URI, or returns an empty string if it does not exist.

Definition at line 695 of file httpserver.cc.

References ion::remote::HttpServer::GetHandlers(), and ion::base::StartsWith().

bool ion::remote::HttpServer::IsRunning ( ) const
inherited

Returns whether the server is running.

Definition at line 710 of file httpserver.cc.

void ion::remote::HttpServer::RegisterHandler ( const RequestHandlerPtr handler)
inherited

Registers the passed handler at the path returned by handler->GetBasePath().

Definition at line 714 of file httpserver.cc.

References DCHECK, ion::base::SharedPtr< T >::Get(), and ion::base::RemoveSuffix().

Referenced by RemoteServer().

bool ion::remote::RemoteServer::RemoveNode ( const gfx::NodePtr node) const

Removes a Node from the NodeGraphHandler.

Note that this only happens if there is a NodeGraphHandler added to Remote. If the Node was not added, this does nothing but return false.

Definition at line 186 of file remoteserver.cc.

References ion::remote::HttpServer::GetHandlers().

void ion::remote::HttpServer::SetEmbedLocalSourcedFiles ( bool  embed)
inlineinherited

Definition at line 145 of file httpserver.h.

void ion::remote::HttpServer::SetFooterHtml ( const std::string &  str)
inlineinherited

Definition at line 158 of file httpserver.h.

References str.

void ion::remote::HttpServer::SetHeaderHtml ( const std::string &  str)
inlineinherited

Definition at line 159 of file httpserver.h.

References str.

void ion::remote::HttpServer::UnregisterHandler ( const std::string &  path)
inherited

Unregisters the handler at path.

Definition at line 724 of file httpserver.cc.

size_t ion::remote::HttpServer::WebsocketCount ( )
inherited

Return the number of currently-connected websockets.

Definition at line 765 of file httpserver.cc.


The documentation for this class was generated from the following files: