protected virtual async Task ProcessHttpRequestMain(HttpRequest request, HttpResponse response, string inStr, string responseContentsType = Consts.MimeTypes.Json) { string ret_str = ""; try { SortedDictionary <string, string> headers = new SortedDictionary <string, string>(); foreach (string headerName in request.Headers.Keys) { if (request.Headers.TryGetValue(headerName, out var val)) { headers.Add(headerName, val.ToString()); } } var conn = request.HttpContext.Connection; JsonRpcClientInfo client_info = new JsonRpcClientInfo(this, conn.LocalIpAddress._UnmapIPv4().ToString(), conn.LocalPort, conn.RemoteIpAddress._UnmapIPv4().ToString(), conn.RemotePort, headers); //string in_str = request.Body.ReadToEnd().GetString_UTF8(); //string in_str = (request.Body.ReadToEnd(this.Config.MaxRequestBodyLen)).GetString_UTF8(); //Dbg.WriteLine("in_str: " + in_str); ret_str = await this.CallMethods(inStr, client_info); } catch (Exception ex) { JsonRpcException json_ex; if (ex is JsonRpcException) { json_ex = (JsonRpcException)ex; } else { json_ex = new JsonRpcException(new JsonRpcError(1234, ex._GetSingleException().Message, ex.ToString())); } ret_str = new JsonRpcResponseError() { Error = json_ex.RpcError, Id = null, Result = null, }._ObjectToJson(); } //Dbg.WriteLine("ret_str: " + ret_str); await response._SendStringContents(ret_str, responseContentsType, cancel : request._GetRequestCancellationToken()); }
public override async Task <object?> StartCallAsync(JsonRpcClientInfo client_info, object?param) { return(null); }
public override object?StartCall(JsonRpcClientInfo client_info) { return(null); }