doug b wrote:
and the dataListener is called whenever there is data to read. However for writing, I do not see a nsIOuputStreamPump, so the loop must be started some other way.

Ah. Well, what the input stream pump does is basically call asyncWait on the stream, and call the listener whenever there's data available.

So what you can do is (pseudo-code):

  function currentEventQueue() {
      var EQS = Components.classes["@mozilla.org/event-queue-service;1"]

.getService(Components.interfaces.nsIEventQueueService);

      return EQS.getSpecialEventQueue(EQS.CURRENT_THREAD_EVENT_QUEUE);
  }

  var callback = {
    onOutputStreamReady: function cb_StreamReady(stream) {
      // Here, insert some code to write to the stream until
      // it throws NS_BASE_STREAM_WOULD_BLOCK

      outStream.asyncWait(callback, 0, 0, currentEventQueue());
    }
  };

  outStream.asyncWait(callback, 0, 0, currentEventQueue());
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to