Esempio n. 1
0
		public void raiseConnectionEvent( object[] args ) {
			NetStream stream = ( NetStream )args[0];
			Console.WriteLine( "http.server.raiseConnectionEvent()" );
			Console.WriteLine( "http.server.raiseConnectionEvent() - calling " + connectionCallbacks.Count + " callbacks" );
			
			foreach( object callback in connectionCallbacks ) {
				( ( IFunction )callback ).Call( this, new object[] { stream } );
			}
		}
Esempio n. 2
0
		public void listenerCallback( IAsyncResult result ) {
			Console.WriteLine( "net.server.listenerCallback()" );
			// TODO: not sure where we should put the call to start listening
			// for the next connection, here for now
			this.tcpServer.BeginAcceptTcpClient( listenerCallback, null );
			
			TcpClient client = this.tcpServer.EndAcceptTcpClient( result );
			NetStream stream = new NetStream( client.GetStream(), Context );
			Server.instance.queueWorkItem( new Callback { callback = raiseConnectionEvent, args = new object[]{ stream } } );
			
			// kick off async read
			stream.read();
		}
Esempio n. 3
0
		public void listenerCallback( IAsyncResult result ) {
			Console.WriteLine( "http.server.listenerCallback()" );
			// TODO: not sure where we should put the call to start listening
			// for the next connection, here for now
			this.tcpServer.BeginAcceptTcpClient( listenerCallback, null );
			
			TcpClient client = this.tcpServer.EndAcceptTcpClient( result );
			NetStream stream = new NetStream( client.GetStream(), Env );
			Server.instance.queueWorkItem( new Callback { name = "raiseConnectionEvent", callback = raiseConnectionEvent, args = new object[]{ stream } } );
			
			// kick off async read
			// stream.read();
		}
Esempio n. 4
0
        public void raiseConnectionEvent(object[] args)
        {
            NetStream stream = ( NetStream )args[0];

            Console.WriteLine("http.server.raiseConnectionEvent() - calling " + connectionCallbacks.Count + " callbacks");

            foreach (object callback in connectionCallbacks)
            {
                Console.WriteLine("calling js function callback");
                // ( ( IFunction )callback ).Call( this, new object[] { stream } );
                IronJS.Function func = (IronJS.Function)callback;
                Action <IronJS.Function, IronJS.Object, IronJS.Object> fun =
                    func.Compiler.compileAs <Action <IronJS.Function, IronJS.Object, IronJS.Object> >(func);
                fun.Invoke(func, this, stream);
            }
        }
Esempio n. 5
0
		public HttpServerResponse( NetStream in_stream, IronJS.Environment env ) : base( env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object ) {
			netStream = in_stream;	
			// Context = in_context;
			
			// this.SetOwnProperty( "write", new Action<string>( write ) );
			var writeMethod = Utils.createHostFunction<Action<string>>(env, write);
            this.Methods.PutRefProperty(this, "write", writeMethod, IronJS.TypeTags.Function);
			
			// this.SetOwnProperty( "end", new Action( end ) );
			var endMethod = Utils.createHostFunction<Action>(env, end);
            this.Methods.PutRefProperty(this, "end", endMethod, IronJS.TypeTags.Function);
			
		} 
Esempio n. 6
0
		public HttpServerRequest( NetStream in_stream, IronJS.Environment env ) : base( env, env.Maps.Base, env.Prototypes.Object, IronJS.Classes.Object ) {
			netStream = in_stream;	
			m_parser = new Parser();
			
			
			// this.SetOwnProperty( "addListener", new Action<string, IFunction>( this.addListener ) );
			var objMethod = Utils.createHostFunction<Action<string, IronJS.FunctionObject>>(env, addListener);
            var objMethod2 = Utils.createHostFunction<Func<string>>(env, getPath);
            this.Methods.PutRefProperty(this, "addListener", objMethod, IronJS.TypeTags.Function);
            this.Methods.PutRefProperty(this, "getPath", objMethod2, IronJS.TypeTags.Function);
		}