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.
A message string. An empty string if no message was read.
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)
running
A boolean indicating if this server is running
new()
Initialize the server.
Server$new(executor = NULL)
executor
The executor to serve
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.
Server$addresses()
A list of address types, with one or more addresses for each type.
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
Server$url()
A URL string of the server
receive()
Receive a request.
Server$receive(request, then)
request
The JsonRpcRequest
(or JSON/list representation of it) to receive.
then
A function to call with the response.
read()
Read a message.
Server$read(blocking = TRUE)
blocking
Should the read be a blocking operation?
write()
Write a message.
Server$write(message)
message
The message to write.
start()
Start the server.
Server$start(executor, background = -1)
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
check()
Server$check(blocking = TRUE)
blocking
Should the read be a blocking operation?
stop()
Stop the server
Derived classes may override this method to gracefully shutdown the server e.g. close client connections.
Server$stop()
clone()
The objects of this class are cloneable with this method.
Server$clone(deep = FALSE)
deep
Whether to make a deep clone.