EASession streams on thread run loop

Is there any example of establishing a EASession streams on a queue run loop besides the main loop?


Here's an example of our approach, but would like to know further details.


dispatchQueue = DispatchQueue()
dispatchQueue?.async {
  session.inputStream?.delegate = self;
  session.outputStream?.delegate = self;
  session.inputStream?.schedule(in: .current, forMode: .default)
  session.outputStream?.schedule(in: .current, forMode: .default)
  session.inputStream?.open()
  session.outputStream?.open()
  RunLoop.current.run()
}

Replies

Only the main queue is guarenteed to run on a specific thread (and therefore a specific runloop).
You need to create an NSThread, start it and use its runloop.