public void emit(string eventname, params IronJS.BoxedValue[] args) { foreach (object callback in Callbacks[eventname]) { log.Trace("calling js function callback: " + eventname); IronJS.FunctionObject func = (IronJS.FunctionObject)callback; func.Call(this, args); } }
public void on(string eventname, IronJS.FunctionObject callback) { log.Trace("EventEmitter - adding listener: " + eventname); // TODO: move listener counts to static field on the emitter Server.instance.Listeners++; // TODO: listen is not an event .. remove this if (Callbacks.ContainsKey(eventname)) { Callbacks[eventname].Add(callback); } // TODO: I think that node allows any event to be registered, // so it probably isn't correct to throw on unexpected event else { throw new Exception("on called for unsupported event"); } }