public async Task <MessageContent> HandleRequest(Peer peer, string id, MessageContent content, ILogger logger) { if (!requestHandlers.TryGetValue(id, out var handler)) { logger.LogError($"Received unknown request: {id}"); return(new MessageContent(MessageStatus.RequestNotSupported, "null")); } try { var response = await handler(peer, content); return(new MessageContent(response.Status, JsonConvert.SerializeObject(response))); } catch (JsonException) { logger.LogError($"Received request with invalid body: {id}"); return(new MessageContent(MessageStatus.InvalidRequestBody, "null")); } }
public abstract void SetResult(MessageContent content);