protected virtual void Execute(RPCRequestInfo ri) { if (ri.RequestError != null) { throw new RPCException("transport", "Failed to receive request body: {0}", ri.RequestError); } string q = info.Sector + ':' + ri.RequestHeader["action"].AsString("") + '~' + ri.RequestHeader["version"].AsString("1"); ActionName acname; ActionName.TryParse(q, out acname); if (acname == null) { throw new RPCException("transport", "No valid action name in request"); } ActionInfo ai = info.LookupAction(acname); if (ai == null || ai.Name != acname) { throw new RPCException("transport", "No such action"); } ri.ActionInfo = ai; ActionInvokeDetails d = (ActionInvokeDetails)ai.Handler; JObject reqData = null; try { reqData = JSON.Parse(Encoding.UTF8.GetString(ri.RequestData, 0, ri.RequestDataLength)).AsObject(); } catch (Exception) { } if (reqData == null) { throw new RPCException("transport", "Failed to parse JSON request body"); } CheckPermissions(ri, d); Logger.LogInfo("Request {0}", ri.ActionInfo); JObject resData = d.Handler(ri, reqData); ri.ResponseData = Encoding.UTF8.GetBytes(JSON.Stringify(resData)); }