protected static void PackInvocationCall([NotNull] IInvocation invocation, [NotNull] Stream toStream) { var methodName = GetMethodNameFromInvocation(invocation); JsonRpcRequestBase payload; if (IsInvocationNotification(invocation)) { payload = new JsonRpcNotification(methodName); } else { payload = new JsonRpcRequest(methodName); } var args = invocation.Arguments; if (args.Length > 0) { payload.Params = new JArray(args); } using (var textWriter = new StreamWriter(toStream, Utilities.Utf8, Utilities.DefaultBufferSize, true)) { Utilities.Serializer.Serialize(textWriter, payload); } }
public async Task Notify(string method, params object[] @params) { var request = new JsonRpcNotification { method = method, @params = @params }; var requestJson = JsonConvert.SerializeObject(request, Formatting.None); await _messageService.Notify(requestJson); }