TTK
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
ttk::WebSocketIO Class Reference

#include <WebSocketIO.h>

Inheritance diagram for ttk::WebSocketIO:
ttk::Debug ttk::BaseClass ttkWebSocketIO

Classes

struct  Message
 

Public Member Functions

 WebSocketIO ()
 
 ~WebSocketIO () override
 
int isListening ()
 
virtual int processEvent (const std::string &eventName, const std::string &eventData="")
 
int startServer (int PortNumber)
 
int stopServer ()
 
int getPortNumber ()
 
int sendString (const std::string &msg) const
 
int sendBinary (const size_t &sizeInBytes, const void *data) const
 
int sendMessage (const Message &msg) const
 
int queueMessage (const std::string &msg)
 
int queueMessage (const size_t &sizeInBytes, const void *data)
 
int queueMessage (const Message &msg)
 
int sendNextQueuedMessage ()
 
int processMessageQueue ()
 
int clearMessageQueue ()
 
- Public Member Functions inherited from ttk::Debug
 Debug ()
 
 ~Debug () override
 
virtual int setDebugLevel (const int &debugLevel)
 
int setWrapper (const Wrapper *wrapper) override
 
int printMsg (const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printMsg (const std::vector< std::string > &msgs, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printErr (const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
 
int printWrn (const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
 
int printMsg (const std::string &msg, const double &progress, const double &time, const int &threads, const double &memory, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
 
int printMsg (const std::string &msg, const double &progress, const double &time, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
 
int printMsg (const std::string &msg, const double &progress, const double &time, const int &threads, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
 
int printMsg (const std::string &msg, const double &progress, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
 
int printMsg (const std::string &msg, const double &progress, const debug::Priority &priority, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printMsg (const std::vector< std::vector< std::string > > &rows, const debug::Priority &priority=debug::Priority::INFO, const bool hasHeader=true, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printMsg (const debug::Separator &separator, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::INFO, std::ostream &stream=std::cout) const
 
int printMsg (const debug::Separator &separator, const debug::Priority &priority, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printMsg (const std::string &msg, const debug::Separator &separator, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::INFO, std::ostream &stream=std::cout) const
 
void setDebugMsgPrefix (const std::string &prefix)
 
- Public Member Functions inherited from ttk::BaseClass
 BaseClass ()
 
virtual ~BaseClass ()=default
 
int getThreadNumber () const
 
virtual int setThreadNumber (const int threadNumber)
 

Additional Inherited Members

- Protected Member Functions inherited from ttk::Debug
int printMsgInternal (const std::string &msg, const std::string &right, const std::string &filler, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
 
int printMsgInternal (const std::string &msg, const debug::Priority &priority, const debug::LineMode &lineMode, std::ostream &stream=std::cout) const
 
int welcomeMsg (std::ostream &stream)
 
- Protected Attributes inherited from ttk::Debug
int debugLevel_
 
std::string debugMsgPrefix_
 
std::string debugMsgNamePrefix_
 
- Protected Attributes inherited from ttk::BaseClass
bool lastObject_
 
int threadNumber_
 
Wrapperwrapper_
 
- Static Protected Attributes inherited from ttk::Debug
static COMMON_EXPORTS debug::LineMode lastLineMode = ttk::debug::LineMode::NEW
 

Detailed Description

Author
Jonas Lukasczyk jl@jl.nosp@m.uk.d.nosp@m.e
Date
13.04.2021

This module provides functions for bi-directional communication between two websockets, where the heavy lifting is done by the websocketpp library. The primary use case for this module is to send data that was computed in a c++ environment to a browser client, which can then freely process/render the data via JavaScript and HTML. To this end, this module needs to run a websocket server, to which a client can connect to via the ttkWebSocketIO.js library. The server can also receive data from the client, which is then fed into the processEvent function. In order to add custom processing of events, one needs to inherit from the WebSocketIO class and override the processEvent method. The vtk wrapper ttkWebSocketIO provides an example on how this abstract base module can be specialized to the application of sending/receiving vtkDataObjects. Specifically, the ttkWebSocketIO filter will send its input vtkDataObject as a serialized JSON object to all connected clients every time the filter is called with a new input. When the server receives a serialized JSON object form the client, then the filter will instantiate a vtkDataObject and pass it as the filter output.

Definition at line 51 of file WebSocketIO.h.

Constructor & Destructor Documentation

◆ WebSocketIO()

ttk::WebSocketIO::WebSocketIO ( )

Definition at line 5 of file WebSocketIO.cpp.

◆ ~WebSocketIO()

ttk::WebSocketIO::~WebSocketIO ( )
override

Definition at line 31 of file WebSocketIO.cpp.

Member Function Documentation

◆ clearMessageQueue()

int ttk::WebSocketIO::clearMessageQueue ( )

Definition at line 329 of file WebSocketIO.cpp.

◆ getPortNumber()

int ttk::WebSocketIO::getPortNumber ( )

Definition at line 301 of file WebSocketIO.cpp.

◆ isListening()

int ttk::WebSocketIO::isListening ( )

Definition at line 298 of file WebSocketIO.cpp.

◆ processEvent()

int ttk::WebSocketIO::processEvent ( const std::string &  eventName,
const std::string &  eventData = "" 
)
virtual

Reimplemented in ttkWebSocketIO.

Definition at line 338 of file WebSocketIO.cpp.

◆ processMessageQueue()

int ttk::WebSocketIO::processMessageQueue ( )

Definition at line 335 of file WebSocketIO.cpp.

◆ queueMessage() [1/3]

int ttk::WebSocketIO::queueMessage ( const Message msg)

Definition at line 326 of file WebSocketIO.cpp.

◆ queueMessage() [2/3]

int ttk::WebSocketIO::queueMessage ( const size_t &  sizeInBytes,
const void *  data 
)

Definition at line 323 of file WebSocketIO.cpp.

◆ queueMessage() [3/3]

int ttk::WebSocketIO::queueMessage ( const std::string &  msg)

Definition at line 320 of file WebSocketIO.cpp.

◆ sendBinary()

int ttk::WebSocketIO::sendBinary ( const size_t &  sizeInBytes,
const void *  data 
) const

Definition at line 313 of file WebSocketIO.cpp.

◆ sendMessage()

int ttk::WebSocketIO::sendMessage ( const Message msg) const

Definition at line 317 of file WebSocketIO.cpp.

◆ sendNextQueuedMessage()

int ttk::WebSocketIO::sendNextQueuedMessage ( )

Definition at line 332 of file WebSocketIO.cpp.

◆ sendString()

int ttk::WebSocketIO::sendString ( const std::string &  msg) const

Definition at line 310 of file WebSocketIO.cpp.

◆ startServer()

int ttk::WebSocketIO::startServer ( int  PortNumber)

Definition at line 304 of file WebSocketIO.cpp.

◆ stopServer()

int ttk::WebSocketIO::stopServer ( )

Definition at line 307 of file WebSocketIO.cpp.


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