private static async void PerformWSAction(HttpListenerContext context, RequestParams reqPar, RPluginCollection plugins, RHttpAction wsact) { var wsc = await context.AcceptWebSocketAsync(wsact.WSProtocol); wsact.WSAction(new RRequest(context.Request, reqPar, plugins), new WebSocketDialog(wsc)); }
private static void PerformAction(HttpListenerContext context, RequestParams reqPar, RPluginCollection plugins, RHttpAction act) { var req = new RRequest(context.Request, reqPar, plugins); var res = new RResponse(context.Response, plugins); act.Action(req, res); }
internal void AddRoute(RHttpAction action, HttpMethod method) { RouteTree rt; if (!_trees.TryGetValue(method, out rt)) { rt = new RouteTree("", null); _trees.Add(method, rt); } AddToTree(rt, action); }
private static RequestParams GetParams(RHttpAction act, string route) { if (!act.Params.Any()) { return(EmptyReqParams); } var rt = route.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var dict = act.Params .Where(kvp => kvp.Key < rt.Length) .ToDictionary(kvp => kvp.Value, kvp => rt[kvp.Key]); return(new RequestParams(dict)); }
private static void AddToTree(RouteTree tree, RHttpAction action) { var rTree = action.RouteTree; var len = rTree.Length; for (var i = 0; i < len; i++) { var ntree = tree. AddBranch(rTree[i]); tree = ntree; } if (tree.Action != null) { throw new RHttpServerException("Cannot add two actions to the same route"); } tree.Action = action; }