Realm C++ SDK Version v2.2.0
Classes | Public Member Functions | Protected Attributes | List of all members

realm::networking::default_socket_provider Struct Reference

Built in websocket provider. More...

#include <websocket.hpp>

Inheritance diagram for realm::networking::default_socket_provider:
realm::networking::sync_socket_provider

Classes

struct  configuration
 

Public Member Functions

 default_socket_provider (const configuration &c)
 
std::unique_ptr< websocket_interfaceconnect (std::unique_ptr< websocket_observer >, websocket_endpoint &&) override
 
void post (FunctionHandler &&) override
 
sync_timer create_timer (std::chrono::milliseconds delay, FunctionHandler &&) override
 
- Public Member Functions inherited from realm::networking::sync_socket_provider
virtual ~sync_socket_provider ()=default
 
virtual std::unique_ptr< websocket_interfaceconnect (std::unique_ptr< websocket_observer > observer, websocket_endpoint &&endpoint)=0
 
virtual void post (FunctionHandler &&handler)=0
 
virtual sync_timer create_timer (std::chrono::milliseconds delay, FunctionHandler &&handler)=0
 

Protected Attributes

configuration m_configuration
 

Additional Inherited Members

- Public Types inherited from realm::networking::sync_socket_provider
using FunctionHandler = std::function< void(status)>
 Function handler typedef.
 
using sync_timer = std::unique_ptr< sync_socket_provider::timer >
 Other class typedefs.
 

Detailed Description

Built in websocket provider.

Member Function Documentation

◆ connect()

std::unique_ptr< websocket_interface > realm::networking::default_socket_provider::connect ( std::unique_ptr< websocket_observer observer,
websocket_endpoint &&  endpoint 
)
overridevirtual

Create a new websocket pointed to the server indicated by endpoint and connect to the server. Any events that occur during the execution of the websocket will call directly to the handlers provided by the observer. The web_socket_observer guarantees that the WebSocket object will be closed/destroyed before the observer is terminated/destroyed.

Implements realm::networking::sync_socket_provider.

◆ create_timer()

default_socket_provider::sync_timer realm::networking::default_socket_provider::create_timer ( std::chrono::milliseconds  delay,
FunctionHandler &&  handler 
)
overridevirtual

Create and register a new timer whose handler function will be posted to the event loop when the provided delay expires.

This is a one shot timer and the Timer class returned becomes invalid once the timer has expired. A new timer will need to be created to wait again.

Parameters
delayThe duration to wait in ms before the timer expires.
handlerThe handler function to be called on the event loop when the timer expires.
Returns
A pointer to the Timer object that can be used to cancel the timer. The timer will also be canceled if the Timer object returned is destroyed.

Implements realm::networking::sync_socket_provider.

◆ post()

void realm::networking::default_socket_provider::post ( FunctionHandler &&  handler)
overridevirtual

Submit a handler function to be executed by the event loop (thread).

Register the specified handler function to be queued on the event loop for immediate asynchronous execution. The specified handler will be executed by an expression on the form handler(). If the the handler object is movable, it will never be copied. Otherwise, it will be copied as necessary.

This function is thread-safe and can be called by any thread. It can also be called from other post() handler function.

The handler will never be called as part of the execution of post(). If post() is called on a thread separate from the event loop, the handler may be called before post() returns.

Handler functions added through post() must be executed in the order they are added. More precisely, if post() is called twice to add two handlers, A and B, and the execution of post(A) ends before the beginning of the execution of post(B), then A is guaranteed to execute before B.

Parameters
handlerThe handler function to be queued on the event loop.

Implements realm::networking::sync_socket_provider.


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