setup method

Future<void> setup()

setup setup is a method to be called very early to negotiate open PeerConnection on which data channels can be created and further operations of text room can be performed.

Implementation

Future<void> setup() async {
  var body = {"request": "setup"};
  await this.send(data: body);
  this.messages?.listen((event) async {
    if (event.jsep != null) {
      await this.handleRemoteJsep(event.jsep);
      var body = {"request": "ack"};
      await this.initDataChannel();
      RTCSessionDescription answer = await this.createAnswer();
      await this.send(
        data: body,
        jsep: answer,
      );
    }
  });
  this._setup = true;
}