public static NSJSObject NewContextObject(NSJSVirtualMachine machine, NSJSObject application, HTTPContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (application == null) { throw new ArgumentNullException("application"); } if (machine == null) { throw new ArgumentNullException("machine"); } NSJSObject objective = NSJSObject.New(machine); // ctx objective.Set("Application", application); objective.Set("Close", m_CloseProc); objective.Set("Dispose", m_CloseProc); objective.Set("Request", HttpRequest.New(machine, objective, context.Request)); objective.Set("Response", HttpResponse.New(machine, objective, context.Response)); objective.DefineProperty("Asynchronous", m_AsynchronousProc, m_AsynchronousProc); NSJSKeyValueCollection.Set(objective, context); return(objective); }
public void ProcessRequest(HTTPContext context) { if (context == null) { return /*undefined*/; } NSJSVirtualMachine machine = this.GetVirtualMachine(); machine.Join((sender, state) => { NSJSFunction function = this.GetProcessRequestCallback(); if (function != null) { NSJSObject context_object = null; try { context_object = this.NewContextObject(context); } catch (Exception) { /*-----*/ } if (context_object != null) { function.Call(context_object); } } }); }
private static void OnEndProcessRequest(object sender, HTTPContext e) { DoProcessRequest(sender, (application, origin, machine) => { NSJSFunction callback = origin.Get("EndProcessRequest") as NSJSFunction; if (callback != null) { callback.Call(HttpHandler.NewContextObject(machine, origin, e)); } }); }
public NSJSObject NewContextObject(HTTPContext context) { return(NewContextObject(this.GetVirtualMachine(), this.Source, context)); }