Viam C++ SDK current
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
viam::sdk::Server Class Reference

Defines gRPC Server functionality. More...

#include "rpc/server.hpp"

Public Member Functions

void start ()
 Starts the grpc server. Can only be called once.
 
void register_service (grpc::Service *service)
 Registers a gRPC service.
 
std::shared_ptr< ResourceServerlookup_resource_server (const API &api)
 Returns reference to managed resource server.
 
void add_resource (std::shared_ptr< Resource > resource)
 Adds a specific managed resource to the associated resource server.
 
void add_listening_port (const std::string &address, std::shared_ptr< grpc::ServerCredentials > creds=nullptr)
 Adds a listening port to the server.
 
void wait ()
 waits on server close, only returning when the server is closed.
 
void shutdown ()
 Shutdown the gRPC server.
 

Friends

class ::viam::sdktests::TestServer
 

Detailed Description

Defines gRPC Server functionality.

Member Function Documentation

◆ add_listening_port()

void viam::sdk::Server::add_listening_port ( const std::string & address,
std::shared_ptr< grpc::ServerCredentials > creds = nullptr )

Adds a listening port to the server.

Parameters
addressThe address to listen at.
credsThe server credentials; defaults to a insecure server credentials.
Exceptions
`Exception`if called after the server has been started.

◆ add_resource()

void viam::sdk::Server::add_resource ( std::shared_ptr< Resource > resource)

Adds a specific managed resource to the associated resource server.

Parameters
resourceThe resource to add
Exceptions
`Exception`if a matching ResourceServer doesn't exist in the server.

◆ lookup_resource_server()

std::shared_ptr< ResourceServer > viam::sdk::Server::lookup_resource_server ( const API & api)

Returns reference to managed resource server.

Parameters
apiThe api of the managed resource server.
Returns
The requested resource server, or nullptr if it doesn't exist.

◆ register_service()

void viam::sdk::Server::register_service ( grpc::Service * service)

Registers a gRPC service.

Parameters
serviceThe gRPC service to be registered.
Exceptions
`Exception`if called after the server has been started.

◆ start()

void viam::sdk::Server::start ( )

Starts the grpc server. Can only be called once.

Exceptions
`Exception`if the server was already started. repeated calls.

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