createConnection method

Future<Connection?>? createConnection(
  1. UserJoinedData data
)

Implementation

Future<Connection?>? createConnection(UserJoinedData data) async {
  if (stream != null) {
    final connection = Connection(
      connectionType: 'incoming',
      userId: data.userId,
      name: data.name,
      stream: stream,
      audioEnabled: data.config!.audioEnabled,
      videoEnabled: data.config!.videoEnabled,
    );
    connection.on('connected', null, (ev, context) {
      print('rtp connected');
    });
    connection.on('candidate', null, (ev, context) {
      sendIceCandidate(connection.userId!, ev.eventData as RTCIceCandidate);
    });
    connection.on('stream-changed', null, (ev, context) {
      emit('stream-changed');
    });
    connections.add(connection);
    await connection.start();
    emit('connection', null, connection);
    return connection;
  }
  return null;
}