class Session

Defined at line 121 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

Session implements a DAP client or server endpoint.

The general usage is as follows:

(1) Create a session with Session::create().

(2) Register request and event handlers with registerHandler().

(3) Optionally register a protocol error handler with onError().

(3) Bind the session to the remote endpoint with bind().

(4) Send requests or events with send().

Public Methods

void ~Session ()
std::unique_ptr<Session> create ()

create() constructs and returns a new Session.

void setOnInvalidData (OnInvalidData )

Sets how the Session handles invalid data.

void onError (const ErrorHandler & )

onError() registers a error handler that will be called whenever a protocol

error is encountered.

Only one error handler can be bound at any given time, and later calls

will replace the existing error handler.

template <typename F, typename RequestType = ParamType<F, 0>>
IsRequestHandlerWithoutCallback<F> registerHandler (F && handler)

registerHandler() registers a request handler for a specific request type.

The function F must have one of the following signatures:

ResponseOrError

<ResponseType

>(const RequestType

&

)

ResponseType(const RequestType

&

)

Error(const RequestType

&

)

Defined at line 340 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename F, typename RequestType = ParamType<F, 0>, typename ResponseType = typename RequestType::Response>
IsRequestHandlerWithCallback<F, ResponseType> registerHandler (F && handler)

registerHandler() registers a request handler for a specific request type.

The handler has a response callback function for the second argument of the

handler function. This callback may be called after the handler has

returned.

The function F must have the following signature:

void(const RequestType

&

request,

std::function

<void

(ResponseType)> response)

Defined at line 359 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename F, typename RequestType = ParamType<F, 0>, typename ResponseType = typename RequestType::Response>
IsRequestHandlerWithCallback<F, ResponseOrError<ResponseType>> registerHandler (F && handler)

registerHandler() registers a request handler for a specific request type.

The handler has a response callback function for the second argument of the

handler function. This callback may be called after the handler has

returned.

The function F must have the following signature:

void(const RequestType

&

request,

std::function

<void

(ResponseOrError

<ResponseType

>)> response)

Defined at line 375 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename F, typename EventType = ParamType<F, 0>>
IsEvent<EventType> registerHandler (F && handler)

registerHandler() registers a event handler for a specific event type.

The function F must have the following signature:

void(const EventType

&

)

Defined at line 396 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename F, typename ResponseType = typename ParamType<F, 0>::Request>
void registerSentHandler (F && handler)

registerSentHandler() registers the function F to be called when a response

of the specific type has been sent.

The function F must have the following signature:

void(const ResponseOrError

<ResponseType

>

&

)

Defined at line 405 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename T, typename = IsRequest<T>>
future<ResponseOrError<typename T::Response>> send (const T & request)

send() sends the request to the connected endpoint and returns a

future that is assigned the request response or error.

Defined at line 418 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

template <typename T, typename = IsEvent<T>>
void send (const T & event)

send() sends the event to the connected endpoint.

Defined at line 437 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

void bind (const std::shared_ptr<Reader> & reader, const std::shared_ptr<Writer> & writer, const ClosedHandler & onClose)

bind() connects this Session to an endpoint using connect(), and then

starts processing incoming messages with startProcessingMessages().

onClose is the optional callback which will be called when the session

endpoint has been closed.

Defined at line 446 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

void bind (const std::shared_ptr<ReaderWriter> & readerWriter, const ClosedHandler & onClose)

Defined at line 453 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

void connect (const std::shared_ptr<Reader> & , const std::shared_ptr<Writer> & )

connect() connects this Session to an endpoint.

connect() can only be called once. Repeated calls will raise an error, but

otherwise will do nothing.

Note: This method is used for explicit control over message handling.

Most users will use bind() instead of calling this method directly.

void connect (const std::shared_ptr<ReaderWriter> & )

Defined at line 442 of file ../../third_party/github.com/google/cppdap/src/include/dap/session.h

void startProcessingMessages (const ClosedHandler & onClose)

startProcessingMessages() starts a new thread to receive and dispatch

incoming messages.

onClose is the optional callback which will be called when the session

endpoint has been closed.

Note: This method is used for explicit control over message handling.

Most users will use bind() instead of calling this method directly.

std::function<void ()> getPayload ()

getPayload() blocks until the next incoming message is received, returning

the payload or an empty function if the connection was lost. The returned

payload is function that can be called on any thread to dispatch the

message to the Session handler.

Note: This method is used for explicit control over message handling.

Most users will use bind() instead of calling this method directly.

void registerHandler (const TypeInfo * typeinfo, const GenericRequestHandler & handler)

registerHandler() registers 'handler' as the request handler callback for

requests of the type 'typeinfo'.

void registerHandler (const TypeInfo * typeinfo, const GenericEventHandler & handler)

registerHandler() registers 'handler' as the event handler callback for

events of the type 'typeinfo'.

void registerHandler (const TypeInfo * typeinfo, const GenericResponseSentHandler & handler)

registerHandler() registers 'handler' as the response-sent handler function

which is called whenever a response of the type 'typeinfo' is sent from

this session endpoint.

bool send (const dap::TypeInfo * requestTypeInfo, const dap::TypeInfo * responseTypeInfo, const void * request, const GenericResponseHandler & responseHandler)

send() sends a request to the remote endpoint.

'requestTypeInfo' is the type info of the request data structure.

'requestTypeInfo' is the type info of the response data structure.

'request' is a pointer to the request data structure.

'responseHandler' is the handler function for the response.

bool send (const TypeInfo * eventTypeInfo, const void * event)

send() sends an event to the remote endpoint.

'eventTypeInfo' is the type info for the event data structure.

'event' is a pointer to the event data structure.