public IronJS.CommonObject CreateServer(IronJS.FunctionObject callback) { Console.WriteLine("http.createServer() called."); Http.HttpServer server = new Http.HttpServer(callback, Env); Console.WriteLine(server); return(server); }
public IronJS.CommonObject CreateServer(IronJS.FunctionObject callback) { log.Trace("net.createServer() called."); Net.NetServer server = new Net.NetServer(callback, Env); log.Trace(server); return(server); }
public void raiseEndEvent(object[] args) { log.Trace("net.stream.raiseEndEvent()"); for (var i = 0; i < endCallbacks.Count; i++) { IronJS.FunctionObject func = (IronJS.FunctionObject)endCallbacks[i]; func.Call(this); } }
public void raiseDataEvent(object[] args) { string chunk = ( string )args[0]; log.Trace("net.stream.raiseDataEvent():" + chunk); for (var i = 0; i < dataCallbacks.Count; i++) { IronJS.FunctionObject func = (IronJS.FunctionObject)dataCallbacks[i]; func.Call <string>(this, chunk); } }
public HttpServer(IronJS.FunctionObject callback, IronJS.Environment env) : base(env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object) { // have to set this stuff up. not sure why yet Console.WriteLine("creating HttpServer"); var objMethod = Utils.createHostFunction <Action <object, string> >(env, listen); // this.Methods.PutRefProperty(this, "listen", objMethod, IronJS.TypeTags.Function); this.Put("listen", objMethod, TypeTags.Function) this.addListener("connection", callback); }
public void addListener(string eventname, IronJS.FunctionObject callback) { Server.instance.Listeners++; log.Trace("NetStream: adding listener: " + eventname); if (eventname == "data") { dataCallbacks.Add(callback); } else if (eventname == "end") { endCallbacks.Add(callback); } }
// TODO: pull this stuff out to an event class public void raiseListeningEvent(object[] args) { Console.WriteLine("http.server.raiseListeningEvent()"); for (var i = 0; i < listeningCallbacks.Count; i++) { // ( ( IronJS.FunctionObject )listeningCallbacks[i] ).Call( this, new object[]{} ); IronJS.FunctionObject func = (IronJS.FunctionObject)listeningCallbacks[i]; /* * Action<IronJS.FunctionObject,IronJS.CommonObject,object[]> fun = * func.Compiler.compileAs<Action<IronJS.FunctionObject,IronJS.CommonObject,object[]>>(func); * fun.Invoke(func, func.Env.Globals, new object[] {} ); */ func.Call(this, new BoxedValue[] { }); } }
public void addListener(string eventname, IronJS.FunctionObject callback) { Console.WriteLine("HttpServerRequest - adding listener: " + eventname); if (eventname == "data") { netStream.addListener("data", callback); } else if (eventname == "end") { netStream.addListener("end", callback); } else { throw new Exception("addListener called for unsupported event"); } }
public void raiseConnectionEventCont() { Console.WriteLine("raiseConnectionEventCont()"); foreach (object callback in connectionCallbacks) { // ( ( IFunction )callback ).Call( this, new object[] { req, resp } ); IronJS.FunctionObject func = (IronJS.FunctionObject)callback; /* * Action<IronJS.FunctionObject,IronJS.CommonObject,IronJS.CommonObject,IronJS.CommonObject> fun = * func.Compiler.compileAs<Action<IronJS.FunctionObject,IronJS.CommonObject,IronJS.CommonObject,IronJS.CommonObject>>(func); * fun.Invoke(func, this, req, resp ); */ func.Call <HttpServerRequest, HttpServerResponse>(this, req, resp); // func.Env.Globals for this? } }
public NetServer(IronJS.FunctionObject callback, IronJS.Environment env) : base(env) { // TODO: move as much of this as possible to EventEmitter Callbacks = new Dictionary <string, ArrayList>() { { "connect", new ArrayList() }, { "close", new ArrayList() } }; log.Trace("creating NetServer"); var objMethod = Utils.createHostFunction <Func <object, string, CommonObject> >(env, listen); var removeAllListenersMethod = Utils.createHostFunction <Action <string> >(env, removeAllListeners); this.Put("listen", objMethod, TypeTags.Function); this.Put("removeAllListeners", removeAllListenersMethod, TypeTags.Function); this.addListener("connect", callback); }
public void addListener(string eventname, IronJS.FunctionObject callback) { Console.WriteLine("HttpServer - adding listener: " + eventname); if (eventname == "listening") { listeningCallbacks.Add(callback); } else if (eventname == "connection") { connectionCallbacks.Add(callback); } else if (eventname == "close") { closeCallbacks.Add(callback); } else { throw new Exception("addListener called for unsupported event"); } }
public void addListener(string eventname, IronJS.FunctionObject callback) { log.Trace("NetServer - adding listener: " + eventname); on(eventname, callback); }