Realm C++ SDK Version v2.2.0
Public Member Functions | List of all members
realm::networking::websocket_observer Struct Referenceabstract

#include <websocket.hpp>

Public Member Functions

virtual void websocket_connected_handler (const std::string &protocol)=0
 
virtual void websocket_error_handler ()=0
 
virtual bool websocket_binary_message_received (std::string_view data)=0
 
virtual bool websocket_closed_handler (bool was_clean, websocket_err_codes error_code, std::string_view message)=0
 

Detailed Description

WebSocket observer interface in the Sync Client that receives the websocket events during operation.

Member Function Documentation

◆ websocket_binary_message_received()

virtual bool realm::networking::websocket_observer::websocket_binary_message_received ( std::string_view  data)
pure virtual

Called whenever a full message has arrived. The WebSocket implementation is responsible for defragmenting fragmented messages internally and delivering a full message to the Sync Client.

Parameters
dataA util::Span containing the data received from the server. The buffer is only valid until the function returns.
Returns
bool designates whether the WebSocket object should continue processing messages. The normal return value is true . False must be returned if the websocket object has been destroyed during execution of the function.

◆ websocket_closed_handler()

virtual bool realm::networking::websocket_observer::websocket_closed_handler ( bool  was_clean,
websocket_err_codes  error_code,
std::string_view  message 
)
pure virtual

Called whenever the WebSocket connection has been closed, either as a result of a WebSocket error or a normal close.

Parameters
was_cleanWas the TCP connection closed after the WebSocket closing handshake was completed.
error_codeThe error code received or synthesized when the websocket was closed.
messageThe message received in the close frame when the websocket was closed.
Returns
bool designates whether the WebSocket object has been destroyed during the execution of this function. The normal return value is True to indicate the WebSocket object is no longer valid. If False is returned, the WebSocket object will be destroyed at some point in the future.

◆ websocket_connected_handler()

virtual void realm::networking::websocket_observer::websocket_connected_handler ( const std::string &  protocol)
pure virtual

Called when the WebSocket is connected, i.e. after the handshake is done. The Sync Client is not allowed to send messages on the socket before the handshake is complete and no message_received callbacks will be called before the handshake is done.

Parameters
protocolThe negotiated subprotocol value returned by the server

◆ websocket_error_handler()

virtual void realm::networking::websocket_observer::websocket_error_handler ( )
pure virtual

Called when an error occurs while establishing the WebSocket connection to the server or during normal operations. No additional binary messages will be processed after this function is called.


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