RPCProcessor

Fiber which runs in the background, reading from a FileReader, and calling methods when requested over the RPC interface.

Constructors

this
this(FileReader reader, File writer)

Constructs this RPC processor using a FileReader to read RPC commands from and a std.stdio.File to write RPC commands to. Creates this fiber with a reasonable fiber size.

Members

Functions

awaitResponse
ResponseMessage awaitResponse(RequestToken tok)

Waits for a response message to a request from the other RPC side. If this is called after the response has already been sent and processed by yielding after sending the request, this will yield forever and use up memory. So it is important, if you are going to await a response, to do it immediately when sending any request.

hasData
bool hasData()
log
void log(Args args)

Calls the window/logMessage method with all arguments concatenated together using text()

notifyMethod
void notifyMethod(string method)

Sends a notification with the given method name to the other RPC side without any parameters.

notifyMethod
void notifyMethod(string method, T value)

Sends a notification with the given method name to the other RPC side with the given value parameter serialized to JSON.

poll
RequestMessage poll()
send
void send(ResponseMessage res)

Sends an RPC response or error. If id, result or error is not given on the response message, they won't be sent. However according to the RPC specification, id must be set in order for this to be a response object. Otherwise on success result must be set or on error error must be set. This also logs the error to stderr if it is given.

send
void send(RequestMessage req)

Sends an RPC request (method call) to the other side. Doesn't do any additional processing.

send
void send(JSONValue raw)

Sends a raw JSON object to the other RPC side.

sendMethod
RequestToken sendMethod(string method)

Sends a request with the given method name to the other RPC side without any parameters. Doesn't handle the response by the other RPC side.

sendMethod
RequestToken sendMethod(string method, T value)

Sends a request with the given method name to the other RPC side with the given value parameter serialized to JSON. Doesn't handle the response by the other RPC side.

sendRequest
ResponseMessage sendRequest(string method, T value)

Sends a request with the given method name to the other RPC side with the given value parameter serialized to JSON. Awaits the response (using yield) and returns once it's there.

stop
void stop()

Instructs the RPC processor to stop at the next IO read instruction.

window
WindowFunctions window()

Convenience wrapper around WindowFunctions for this.

Meta