Changeset 17

Show
Ignore:
Timestamp:
02/25/06 12:12:56 (3 years ago)
Author:
atack2
Message:

Added a whole host of comments, started the process of waiting for input.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • test_projects/pseudoServer/content/overlay.js

    r16 r17  
     1//* 
     2//* myDump(theMessage) 
     3//* 
     4//*     Display the given message in the Javascript console.  No titles or 
     5//* other information will be displayed with it. 
     6//* 
     7//* PARAMETER: 
     8//*     theMessage: The message to be displayed: 
     9//* 
    110function myDump(theMessage){ 
    211        var consoleService = Components.classes["@mozilla.org/consoleservice;1"] 
     
    413        consoleService.logStringMessage("Server: " + theMessage); 
    514} 
     15myDump("Hello!"); 
    616 
    717 
     18// Set up the listening server. 
    819var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"] 
    9                      .createInstance(Components.interfaces.nsIServerSocket); 
     20                                                        .createInstance(Components.interfaces.nsIServerSocket); 
     21 
     22 
     23 
     24//*                                                      
     25//* This will create the listener for the server socket. 
     26//* IMPLEMENTS: nsIServerSocketListener 
     27//* 
    1028var listener =  
    1129{ 
     30        //* 
     31        //* onSocketAccepted 
     32        //* 
     33        //* Called when the server socket accepts a new connection.  This 
     34        //* connection is passed to an nsITransport, included as a parameter. 
     35        //* 
     36        //* PARAMETERS: 
     37        //*             serverSocket: The socket which took the connection 
     38        //*             transport: The nsITransport generated by accepting the connection. 
     39        //* 
    1240        onSocketAccepted : function(serverSocket, transport)    { 
    1341                try     { 
    1442                        var outputString = "HTTP/1.1 206 PARTIAL-CONTENT\r\n" + 
    1543                                "Content-type: text/plain\r\n" + 
    16                                 "Overhaul-hosts: 130.126.61.78:7055\r\n\r\n" 
     44                                "Overhaul-hosts: 130.126.61.78:7055\r\n\r\n" + 
    1745                                "Hello there " + transport.host + "\n"; 
    1846                         
    1947                        var stream = transport.openOutputStream(0,0,0); 
    2048                                        stream.write(outputString,outputString.length); 
    21                                         stream.close(); 
    2249                        myDump("Sent"); 
    23     } catch(ex2){ dump("::"+ex2); } 
     50                                 
     51                        // Get an Event Sink for accepted connections.   
     52                        var input = transport.openInputStream(0,0,0); 
     53                        var scriptablestream = Components.classes["@mozilla.org/scriptableinputstream;1"] 
     54                        .createInstance(Components.interfaces.nsIScriptableInputStream); 
     55                        scriptablestream.init(stream); 
     56                } catch(ex2){ dump("::"+ex2); } 
    2457        } 
    2558} 
    26                       
     59 
     60 
     61// Initialize the server socket.                                 
    2762serverSocket.init(7055,false,-1); 
    2863serverSocket.asyncListen(listener)