| | 22 | //* |
|---|
| | 23 | //* This is the listener for accepted connections, and it will handle |
|---|
| | 24 | //* the passage of data |
|---|
| | 25 | //* |
|---|
| | 26 | |
|---|
| | 27 | var dataListener = { |
|---|
| | 28 | contentRead : "", |
|---|
| | 29 | |
|---|
| | 30 | onStartRequest: function(request, context) { |
|---|
| | 31 | myDump("Starting receive step!"); |
|---|
| | 32 | }, |
|---|
| | 33 | |
|---|
| | 34 | onStopRequest: function(request, context, status) { |
|---|
| | 35 | myDump("Receiving complete!"); |
|---|
| | 36 | }, |
|---|
| | 37 | |
|---|
| | 38 | onDataAvailable: function(request, context, inputStream, offset, count) { |
|---|
| | 39 | var sinput = Components.classes["@mozilla.org/scriptableinputstream;1"] |
|---|
| | 40 | .createInstance(Components.interfaces.nsIScriptableInputStream); |
|---|
| | 41 | sinput.init(inputStream); |
|---|
| | 42 | myDump("Data is available: " + sinput.read(count)); |
|---|
| | 43 | }, |
|---|
| | 44 | }; |
|---|
| | 45 | |
|---|
| 47 | | var stream = transport.openOutputStream(0,0,0); |
|---|
| 48 | | stream.write(outputString,outputString.length); |
|---|
| 49 | | myDump("Sent"); |
|---|
| | 67 | // Write the message back. |
|---|
| | 68 | var output = transport.openOutputStream(0,0,0); |
|---|
| | 69 | output.write(outputString,outputString.length); |
|---|
| | 70 | myDump("Sent OK header"); |
|---|
| 53 | | var scriptablestream = Components.classes["@mozilla.org/scriptableinputstream;1"] |
|---|
| 54 | | .createInstance(Components.interfaces.nsIScriptableInputStream); |
|---|
| 55 | | scriptablestream.init(stream); |
|---|
| | 74 | |
|---|
| | 75 | // Set up a pump to funnel input to a listener |
|---|
| | 76 | var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]. |
|---|
| | 77 | createInstance(Components.interfaces.nsIInputStreamPump); |
|---|
| | 78 | pump.init(input, -1, -1, 0, 0, false); |
|---|
| | 79 | pump.asyncRead(dataListener,null); |
|---|
| | 80 | myDump("Should be pumping..."); |
|---|
| | 81 | |
|---|
| | 82 | |
|---|