Robot Raconteur Core C++ Library
Public Member Functions | List of all members
RobotRaconteur::BrowserWebSocketTransport Class Reference

Transport for creating client connections inside a web browser using WebSockets. More...

Inheritance diagram for RobotRaconteur::BrowserWebSocketTransport:
RobotRaconteur::Transport

Public Member Functions

 BrowserWebSocketTransport (boost::shared_ptr< RobotRaconteurNode > node=RobotRaconteurNode::sp())
 Construct a new BrowserWebSocketTransport. More...
 
virtual int32_t GetDefaultHeartbeatPeriod ()
 Get the default heartbeat period. More...
 
virtual void SetDefaultHeartbeatPeriod (int32_t milliseconds)
 Set the default heartbeat period. More...
 
virtual bool GetDisableMessage4 ()
 Get disable Message Format Version 4. More...
 
virtual void SetDisableMessage4 (bool d)
 Set disable Message Format Version 4. More...
 
virtual bool GetDisableStringTable ()
 Get disable string table. More...
 
virtual void SetDisableStringTable (bool d)
 Set disable string table. More...
 
virtual bool GetDisableAsyncMessageIO ()
 Get if async message io is disabled. More...
 
virtual void SetDisableAsyncMessageIO (bool d)
 Set if async message io is disabled. More...
 
virtual int32_t GetMaxMessageSize ()
 Get the maximum serialized message size. More...
 
virtual void SetMaxMessageSize (int32_t size)
 Set the maximum serialized message size. More...
 

Detailed Description

Transport for creating client connections inside a web browser using WebSockets.

Robot Raconteur can be compiled to run inside a web browser using Emscripten and WebAssembly (WASM). While inside a web browser, the only connection method currently available to connection to a Robot Raconteur service is using WebSockets. The BrowserWebSocketTransport class implements the WebSocket transport for the web browser. Currently only the client side is implemented.

See robotraconteur_url for more information on URLs.

Currently the url connections schemes rr+ws, rr+wss and rr+tcp are supported. rr+tcp are treated as rr+ws connections.

BrowserWebSocketTransport must be manually registered with the node using RobotRaconteurNode::RegisterTransport(). NodeSetup is not currently available in the web browser.

Note that for services to accept a WebSocket connection, the service must have the WebSocket "origin" configured correctly. The origin is the base URL of the web page that is hosting the web page that is connecting to the service. For example, if the web page is hosted at https://example.com/application/index.html, the origin would be https://example.com. For localhost, the origin is http://localhost:8080, where 8080 is the port the web page is hosted on. The origin can be configured using the function TcpTransport::AddWebSocketAllowedOrigin(), or using the --robotraconteur-tcp-ws-add-origin command line option if a node setup class is used. If a local file is used to host the web page, the origin is null and no origin checking is performed.

See TcpTransport::AddWebSocketAllowedOrigin() for more information on configuring the WebSocket origin and the default origins that are automatically configured.

Constructor & Destructor Documentation

◆ BrowserWebSocketTransport()

RobotRaconteur::BrowserWebSocketTransport::BrowserWebSocketTransport ( boost::shared_ptr< RobotRaconteurNode node = RobotRaconteurNode::sp())

Construct a new BrowserWebSocketTransport.

Must use boost::make_shared<BrowserWebSocketTransport>()

The transport must be registered with the node using RobotRaconteurNode::RegisterTransport() after construction.

Parameters
nodeThe node that will use the transport. Default is the singleton node

Member Function Documentation

◆ GetDefaultHeartbeatPeriod()

virtual int32_t RobotRaconteur::BrowserWebSocketTransport::GetDefaultHeartbeatPeriod ( )
virtual

Get the default heartbeat period.

The heartbeat is used to keep the connection alive if no communication is occuring between nodes.

Default: 5 seconds

Returns
int32_t The period in milliseconds

◆ GetDisableAsyncMessageIO()

virtual bool RobotRaconteur::BrowserWebSocketTransport::GetDisableAsyncMessageIO ( )
virtual

Get if async message io is disabled.

Async message io has better memory handling, at the expense of slightly higher latency.

Default: Async io disabled

Returns
true Async message io is disabled
false Async message io is not disabled

◆ GetDisableMessage4()

virtual bool RobotRaconteur::BrowserWebSocketTransport::GetDisableMessage4 ( )
virtual

Get disable Message Format Version 4.

Message Format Version 2 will be used

Default: Message V4 is enabled

Returns
true Disable Message V4
false Enable Message V4

◆ GetDisableStringTable()

virtual bool RobotRaconteur::BrowserWebSocketTransport::GetDisableStringTable ( )
virtual

Get disable string table.

Default: false

RobotRaconteurNodeSetup and its subclasses will disable the string table by default

Returns
true Disable the string table
false String table is not disabled

◆ GetMaxMessageSize()

virtual int32_t RobotRaconteur::BrowserWebSocketTransport::GetMaxMessageSize ( )
virtual

Get the maximum serialized message size.

Default: 10 MB

Returns
int32_t The size in bytes

◆ SetDefaultHeartbeatPeriod()

virtual void RobotRaconteur::BrowserWebSocketTransport::SetDefaultHeartbeatPeriod ( int32_t  milliseconds)
virtual

Set the default heartbeat period.

The heartbeat is used to keep the connection alive if no communication is occuring between nodes.

Default: 5 seconds

Parameters
millisecondsThe heartbeat in milliseconds

◆ SetDisableAsyncMessageIO()

virtual void RobotRaconteur::BrowserWebSocketTransport::SetDisableAsyncMessageIO ( bool  d)
virtual

Set if async message io is disabled.

Async message io is not well supported by this transport. Enabling async message io is not recommended.

Async message io has better memory handling, at the expense of slightly higher latency.

Default: Async io disabled

Parameters
dIf true, async io is disabled

◆ SetDisableMessage4()

virtual void RobotRaconteur::BrowserWebSocketTransport::SetDisableMessage4 ( bool  d)
virtual

Set disable Message Format Version 4.

Message Format Version 2 will be used

Default: Message V4 is enabled

Parameters
dIf true, Message V4 is disabled

◆ SetDisableStringTable()

virtual void RobotRaconteur::BrowserWebSocketTransport::SetDisableStringTable ( bool  d)
virtual

Set disable string table.

Default: false

RobotRaconteurNodeSetup and its subclasses will disable the string table by default

Parameters
dIf true, string table is disabled

◆ SetMaxMessageSize()

virtual void RobotRaconteur::BrowserWebSocketTransport::SetMaxMessageSize ( int32_t  size)
virtual

Set the maximum serialized message size.

Default: 10 MB

Parameters
sizeThe size in bytes

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