A server is responsible for receiving requests to call an executor method. This is an abstract base class for concrete classes of servers that will each communicate with clients over alternative transports (e.g. stdio, HTTP).

R implementation of Executa's Server interface.

Value

A message string. An empty string if no message was read.

Note

Derived classes will usually want to override this method to read a message from a specific transport.

Derived classes will usually want to override this method to write a message to a specific transport.

When overriding this method, derived classes will usually want to call this method, i.e super$start(executor)

Public fields

running

A boolean indicating if this server is running

Methods

Public methods


Method new()

Initialize the server.

Usage

Server$new(executor = NULL)

Arguments

executor

The executor to serve


Method addresses()

Get the addresses of the server.

A server will usually on have one address type (e.g. stdio or http) but may have more than one address for each type.

Usage

Server$addresses()

Returns

A list of address types, with one or more addresses for each type.


Method url()

Get the URL of the server.

The URL is derived from the first address. Intended mainly for easily adding the address of the server to log messages

Usage

Server$url()

Returns

A URL string of the server


Method receive()

Receive a request.

Usage

Server$receive(request, then)

Arguments

request

The JsonRpcRequest (or JSON/list representation of it) to receive.

then

A function to call with the response.


Method read()

Read a message.

Usage

Server$read(blocking = TRUE)

Arguments

blocking

Should the read be a blocking operation?


Method write()

Write a message.

Usage

Server$write(message)

Arguments

message

The message to write.


Method start()

Start the server.

Usage

Server$start(executor, background = -1)

Arguments

executor

The executor to dispatch to

background

Run the server in the background with this duration (s). between checks for new messages. Check the incoming message stream and handle any messages


Method check()

Usage

Server$check(blocking = TRUE)

Arguments

blocking

Should the read be a blocking operation?


Method stop()

Stop the server

Derived classes may override this method to gracefully shutdown the server e.g. close client connections.

Usage

Server$stop()


Method clone()

The objects of this class are cloneable with this method.

Usage

Server$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.