Instance Method
process(_:completion:)
Processes the given message and responds using the given completion closure.
func process(_ message: Data, completion: @escaping (Data) -> ())
Parameters
messageThe message the server should process.
completionThe closure the server calls when the message has been processed.
Discussion
The given message is expected to be a DocumentationServer.Message, encoded as JSON. If the server cannot decode the message, the completion closure is called with a DocumentationServerError message of type “unsupported-message-type”, encoded in JSON format.
Once decoded, the server uses the message’s type to determine a service that can handle the message. If no service can handle the message, the completion closure is called with a DocumentationServerError message of type “invalid-message”, encoded in JSON format.