Robot Raconteur Core C++ Library
|
Transport for creating client connections inside a web browser using WebSockets. More...
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... | |
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.
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.
node | The node that will use the transport. Default is the singleton node |
|
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
|
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
|
virtual |
Get disable Message Format Version 4.
Message Format Version 2 will be used
Default: Message V4 is enabled
|
virtual |
Get disable string table.
Default: false
RobotRaconteurNodeSetup and its subclasses will disable the string table by default
|
virtual |
Get the maximum serialized message size.
Default: 10 MB
|
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
milliseconds | The heartbeat in milliseconds |
|
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
d | If true, async io is disabled |
|
virtual |
Set disable Message Format Version 4.
Message Format Version 2 will be used
Default: Message V4 is enabled
d | If true, Message V4 is disabled |
|
virtual |
Set disable string table.
Default: false
RobotRaconteurNodeSetup and its subclasses will disable the string table by default
d | If true, string table is disabled |
|
virtual |
Set the maximum serialized message size.
Default: 10 MB
size | The size in bytes |