Stormancer::Scene Class Referenceabstract

Classes

struct  RouteOptions
 Additional options for route registration. More...
 

Public Member Functions

virtual pplx::task< void > disconnect (pplx::cancellation_token ct=pplx::cancellation_token::none())=0
 
void addRoute (const std::string &routeName, std::function< void(Packetisp_ptr)> handler, MessageOriginFilter origin=MessageOriginFilter::Host, const std::unordered_map< std::string, std::string > &metadata=std::unordered_map< std::string, std::string >())
 
virtual void addRoute (const std::string &routeName, std::function< void(Packetisp_ptr)> handler, const RouteOptions &options)=0
 Add a route to the scene. More...
 
template<typename Arg >
void addRoute (const std::string &routeName, std::function< void(const Arg &t)> handler, MessageOriginFilter origin=MessageOriginFilter::Host, const std::unordered_map< std::string, std::string > &metadata=std::unordered_map< std::string, std::string >())
 
template<typename Arg >
void addRoute (const std::string &routeName, std::function< void(const Arg &t)> handler, const RouteOptions &options)
 
virtual void send (const PeerFilter &peerFilter, const std::string &routeName, const StreamWriter &streamWriter, PacketPriority priority=PacketPriority::MEDIUM_PRIORITY, PacketReliability reliability=PacketReliability::RELIABLE_ORDERED, const std::string &channelIdentifier="")=0
 
virtual void send (const std::string &routeName, const StreamWriter &streamWriter, PacketPriority priority=PacketPriority::MEDIUM_PRIORITY, PacketReliability reliability=PacketReliability::RELIABLE_ORDERED, const std::string &channelIdentifier="")=0
 
virtual ConnectionState getCurrentConnectionState () const =0
 Returns the connection state to the the scene.
 
virtual rxcpp::observable< ConnectionStategetConnectionStateChangedObservable () const =0
 
virtual std::string id () const =0
 Returns the scene id.
 
virtual SceneAddress address () const =0
 Returns the detailed scene address, including cluster, account and app information.
 
virtual std::string getHostMetadata (const std::string &key) const =0
 Returns a host metadata value.
 
virtual std::weak_ptr< IConnectionhostConnection () const =0
 Returns the host connection.
 
virtual std::vector< Route_ptr > localRoutes () const =0
 Returns a copy of the local routes.
 
virtual std::vector< Route_ptr > remoteRoutes () const =0
 Returns a copy of the remote routes.
 
rxcpp::observable< Packetisp_ptr > onMessage (const std::string &routeName, MessageOriginFilter filter=MessageOriginFilter::Host, const std::unordered_map< std::string, std::string > &metadata=std::unordered_map< std::string, std::string >())
 
virtual rxcpp::observable< Packetisp_ptr > onMessage (const std::string &routeName, const RouteOptions &options)=0
 
virtual std::vector< std::shared_ptr< IScenePeer > > remotePeers () const =0
 
virtual std::shared_ptr< IScenePeerhost () const =0
 Returns the peer connection to the host.
 
virtual const DependencyScopedependencyResolver () const =0
 
virtual Event< Packet_ptr > & onPacketReceived ()=0
 Fire when a packet is received in the scene.
 
virtual bool isHost () const =0
 
virtual const std::unordered_map< std::string, std::shared_ptr< IP2PScenePeer > > & connectedPeers () const =0
 Obtain the list of peers that are connected directly to this client (through P2P) on this scene. More...
 
virtual Event< std::shared_ptr< IP2PScenePeer > > & onPeerConnected () const =0
 
virtual Event< std::shared_ptr< IP2PScenePeer > > & onPeerDisconnected () const =0
 
virtual rxcpp::observable< P2PConnectionStateChangedArgsp2pConnectionStateChanged () const =0
 
virtual std::shared_ptr< P2PTunnelregisterP2PServer (const std::string &p2pServerId)=0
 
virtual pplx::task< std::shared_ptr< IP2PScenePeer > > openP2PConnection (const std::string &p2pToken, pplx::cancellation_token ct=pplx::cancellation_token::none())=0
 
virtual const std::unordered_map< std::string, std::string > & getSceneMetadata ()=0
 

Member Function Documentation

◆ addRoute() [1/2]

virtual void Stormancer::Scene::addRoute ( const std::string &  routeName,
std::function< void(Packetisp_ptr)>  handler,
const RouteOptions options 
)
pure virtual

Add a route to the scene.

<remark>Add a route for each different message type.</remark>

Parameters
routeNameRoute name.
handlerFunction which handle the receiving messages from the server on the route.
optionsAdditional route options.

◆ addRoute() [2/2]

void Stormancer::Scene::addRoute ( const std::string &  routeName,
std::function< void(Packetisp_ptr)>  handler,
MessageOriginFilter  origin = MessageOriginFilter::Host,
const std::unordered_map< std::string, std::string > &  metadata = std::unordered_map<std::string, std::string>() 
)
inline

Add a route to the scene.

Remarks
Add a route for each different message type.
Parameters
routeNameRoute name.
handlerFunction which handle the receiving messages from the server on the route.
metadataMetadatas about the Route.
dispatchMethodHow to dispatch handler when a message is received on the route.

◆ connectedPeers()

virtual const std::unordered_map<std::string, std::shared_ptr<IP2PScenePeer> >& Stormancer::Scene::connectedPeers ( ) const
pure virtual

Obtain the list of peers that are connected directly to this client (through P2P) on this scene.

Returns
A map of connected peers that has the format [Session Id of the peer] -> [IP2PScenePeer].

◆ disconnect()

virtual pplx::task<void> Stormancer::Scene::disconnect ( pplx::cancellation_token  ct = pplx::cancellation_token::none())
pure virtual

Disconnect from the scene.

Parameters
ctCancellation token used as a timeout. The disconnection can't be cancelled, but some internal operations will be bypassed if the ct is cancelled.
Returns
a completed task when the operation is finished or cancelled. It should never be cancelled or failed.

◆ onMessage()

rxcpp::observable<Packetisp_ptr> Stormancer::Scene::onMessage ( const std::string &  routeName,
MessageOriginFilter  filter = MessageOriginFilter::Host,
const std::unordered_map< std::string, std::string > &  metadata = std::unordered_map<std::string, std::string>() 
)
inline

Creates an IObservable<Packet> instance that listen to events on the specified route.

Parameters
Astring containing the name of the route to listen to.
Returns
An IObservable<Packet> instance that fires each time a message is received on the route.

◆ remotePeers()

virtual std::vector<std::shared_ptr<IScenePeer> > Stormancer::Scene::remotePeers ( ) const
pure virtual

Get a vector containing the scene host connections.

Returns
A vector containing the scene host connections.

◆ send() [1/2]

virtual void Stormancer::Scene::send ( const PeerFilter peerFilter,
const std::string &  routeName,
const StreamWriter &  streamWriter,
PacketPriority  priority = PacketPriority::MEDIUM_PRIORITY,
PacketReliability  reliability = PacketReliability::RELIABLE_ORDERED,
const std::string &  channelIdentifier = "" 
)
pure virtual

Send a packet to a route.

Parameters
peerFilterPeer receiver.
routeNameRoute name.
streamWriterFunction where we write the data in the byte stream.
priorityMessage priority on the network.
reliabilityMessage reliability behavior.

◆ send() [2/2]

virtual void Stormancer::Scene::send ( const std::string &  routeName,
const StreamWriter &  streamWriter,
PacketPriority  priority = PacketPriority::MEDIUM_PRIORITY,
PacketReliability  reliability = PacketReliability::RELIABLE_ORDERED,
const std::string &  channelIdentifier = "" 
)
pure virtual

Send a packet to a route.

Parameters
routeNameRoute name.
streamWriterFunction where we write the data in the byte stream.
priorityMessage priority on the network.
reliabilityMessage reliability behavior.

The documentation for this class was generated from the following file:
  • stormancer/stormancer-sources/include/public/stormancer/Scene.h