Changeset 70

Show
Ignore:
Timestamp:
09/16/06 14:03:39 (2 years ago)
Author:
ajtack
Message:

Fixed formatting of the file such that braces match on the appropriate indentation levels.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/overhaul_replyer.js

    r69 r70  
    11// for client reply 
    2 function overhaul_replyer(receivedDataArray)
     2function overhaul_replyer(receivedDataArray)   
    33        // Set up the listening server. 
    44        var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"] 
     
    77        serverSocket.init(7055,false,-1); 
    88         
    9         var receivedData=""; 
     9        var receivedData = ""; 
    1010         
    1111        var serverListener = { 
    12         //* 
    13         //* onSocketAccepted 
    14         //* 
    15         //* Called when the server socket accepts a new connection.  This 
    16         //* connection is passed to an nsITransport, included as a parameter. 
    17         //* 
    18         //* PARAMETERS: 
    19         //*           serverSocket: The socket which took the connection 
    20         //*           transport: The nsITransport generated by accepting the connection. 
    21         //* 
    22         onSocketAccepted : function(serverSocket, transport)
     12               //* 
     13               //* onSocketAccepted 
     14               //* 
     15               //* Called when the server socket accepts a new connection.  This 
     16               //* connection is passed to an nsITransport, included as a parameter. 
     17               //* 
     18               //* PARAMETERS: 
     19               //*            serverSocket: The socket which took the connection 
     20               //*            transport: The nsITransport generated by accepting the connection. 
     21               //* 
     22               onSocketAccepted : function(serverSocket, transport)   
    2323                 
    24                 // output 
    25                 var output = transport.openOutputStream(0,0,0); 
     24                       // output 
     25                       var output = transport.openOutputStream(0,0,0); 
    2626                 
    27                 // Get an input stream for this transport.     
    28                 var input = transport.openInputStream(0,0,0); 
     27                       // Get an input stream for this transport.      
     28                       var input = transport.openInputStream(0,0,0); 
    2929                 
    3030                bind_stream_to_listener(dataListener, input); 
    3131                /*               
    32               // Set up a pump to funnel input to a listener 
    33               var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. 
    34                 createInstance(Components.interfaces.nsIInputStreamPump); 
    35                 pump.init(input, -1, -1, 0, 0, false); 
    36                 pump.asyncRead(dataListener,null); 
     32                      // Set up a pump to funnel input to a listener 
     33                      var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. 
     34                       createInstance(Components.interfaces.nsIInputStreamPump); 
     35                       pump.init(input, -1, -1, 0, 0, false); 
     36                       pump.asyncRead(dataListener,null); 
    3737                */ 
    3838                 
    3939                 
    40                 //* 
    41                 //* This is the listener for accepted connections, and it will handle 
    42                 //* the passage of data 
    43                 //*  
     40                       //* 
     41                       //* This is the listener for accepted connections, and it will handle 
     42                       //* the passage of data 
     43                       //*  
    4444 
    45                 var dataListener = {   
    46                         onStartRequest: function(request, context)    {       }, 
     45                       var dataListener = {    
     46                               onStartRequest: function(request, context)     {       }, 
    4747                         
    48                         onStopRequest: function(request, context, status)       { 
    49                                 if(receivedData.substring(0,3) == "INFO"){ 
    50                                         var ownChunkList = new Array(); 
    51                                         var curChunk; 
    52                                         for(curChunk = 0; curChunk < numChunk; curChunk++)      { 
    53                                                 if(chunks_held[curChunk] != null) 
    54                                                         ownChunkList[curChunk] = true; 
    55                                                 else 
    56                                                         ownChunkList[curChunk] = false; 
     48                                onStopRequest: function(request, context, status)       { 
     49                                        if(receivedData.substring(0,3) == "INFO")       { 
     50                                                var ownChunkList = new Array(); 
     51                                                var curChunk; 
     52                                                for(curChunk = 0; curChunk < numChunk; curChunk++)      { 
     53                                                        if(chunks_held[curChunk] != null) 
     54                                                                ownChunkList[curChunk] = true; 
     55                                                        else 
     56                                                                ownChunkList[curChunk] = false; 
     57                                                } 
     58                                                output.write(ownChunkList,ownChunkList.length); 
    5759                                        } 
    58                                         output.write(ownChunkList,ownChunkList.length); 
    59                                  
    60                                 } 
    61                                 else{ 
    62                                         for(curChar;curChar<receivedData.length;curChar++){ 
    63                                                 if(receivedData.substring(curChar,curChar+5)=="CHUNK "){ 
    64                                                         var temp=receivedDataArray[receivedData.substring(curChar+6,curChar+6)]; 
    65                                                         output.write(temp,temp.length); 
    66                                                         break; 
     60                                        else    { 
     61                                                for(curChar;curChar<receivedData.length;curChar++){ 
     62                                                        if(receivedData.substring(curChar,curChar+5)=="CHUNK "){ 
     63                                                                var temp=receivedDataArray[receivedData.substring(curChar+6,curChar+6)]; 
     64                                                                output.write(temp,temp.length); 
     65                                                                break; 
     66                                                        } 
    6767                                                } 
    6868                                        } 
    69                                 } 
    70                                                        }, 
    71                         onDataAvailable: function(request, context, inputStream, offset, count)        { 
    72                                 var sinput = Components.classes["@mozilla.org/scriptableinputstream;1"] 
    73                                                .createInstance(Components.interfaces.nsIScriptableInputStream); 
    74                                 sinput.init(inputStream); 
    75                                 receivedData+= sinput.read(count); 
    76                 } 
    77         }; 
    78   
    79         } 
    80 
    81 } 
     69                                }, 
     70                                 
     71                                
     72                                onDataAvailable: function(request, context, inputStream, offset, count)        { 
     73                                        var sinput = Components.classes["@mozilla.org/scriptableinputstream;1"] 
     74                                                       .createInstance(Components.interfaces.nsIScriptableInputStream); 
     75                                       sinput.init(inputStream); 
     76                                       receivedData+= sinput.read(count); 
     77                               }, 
     78                        }; 
     79               }               // Closes onSocketAccepted 
     80        }               // Closes serverListener 
     81}              // Closes overhaul_replyer