leave() {
    if (!cache.user) {
      return Promise.reject(new Error('Only an authenticated user can leave a Room.'));
    }
    Log.i('Room~leave', this);
    // Cancel onDisconnect
    const uid = cache.user.uid.split('/').join(':');
    DataSync.onDisconnect(`_/rooms/${this.uid}/participants/${uid}/status`).cancel();

    // Disconnect user's callbacks
    Object.keys(this._callbacks).forEach((event) => {
      DataSync.off(Events.room.toPath(event)(this), event);
    });
    // Unpublish all published local streams
    this.localStreams()
      .then(localStreams => localStreams.forEach(localStream => localStream.close()));
    // Unsubscribe all remote streams
    this.remoteStreams()
      .then(remoteStreams => remoteStreams.forEach(remoteStream => remoteStream.unSubscribe()));
    // Update status
    return DataSync.set(`_/rooms/${this.uid}/participants/${uid}/status`, WAS_CONNECTED)
    // return DataSync.set(`_/rooms/${this.uid}/participants/${shortUserId}/status`, WAS_CONNECTED)
      .catch(Log.r('Room~leave'));
  }
/**
   * Leave the room. Sets the connected status of the current participant to WAS_CONNECTED,
   * deletes medias and callbacks, closes WebRTC stacks in use.
   * @return {Promise}
   */
Leave the room. Sets the connected status of the current participant to WAS_CONNECTED,
deletes medias and callbacks, closes WebRTC stacks in use.
@return {Promise}
Leave the room . Sets the connected status of the current participant to WAS_CONNECTED deletes medias and callbacks closes WebRTC stacks in use . @return { Promise }
leave() {
    if (!cache.user) {
      return Promise.reject(new Error('Only an authenticated user can leave a Room.'));
    }
    Log.i('Room~leave', this);
    const uid = cache.user.uid.split('/').join(':');
    DataSync.onDisconnect(`_/rooms/${this.uid}/participants/${uid}/status`).cancel();
    Object.keys(this._callbacks).forEach((event) => {
      DataSync.off(Events.room.toPath(event)(this), event);
    });
    this.localStreams()
      .then(localStreams => localStreams.forEach(localStream => localStream.close()));
    this.remoteStreams()
      .then(remoteStreams => remoteStreams.forEach(remoteStream => remoteStream.unSubscribe()));
    return DataSync.set(`_/rooms/${this.uid}/participants/${uid}/status`, WAS_CONNECTED)
      .catch(Log.r('Room~leave'));
  }
leave ( ) { if ( ! cache . user ) { return Promise . reject ( new Error ( 'Only an authenticated user can leave a Room.' ) ) ; } Log . i ( 'Room~leave' , this ) ; const uid = cache . user . uid . split ( '/' ) . join ( ':' ) ; DataSync . onDisconnect ( ` ${ this . uid } ${ uid } ` ) . cancel ( ) ; Object . keys ( this . _callbacks ) . forEach ( ( event ) => { DataSync . off ( Events . room . toPath ( event ) ( this ) , event ) ; } ) ; this . localStreams ( ) . then ( localStreams => localStreams . forEach ( localStream => localStream . close ( ) ) ) ; this . remoteStreams ( ) . then ( remoteStreams => remoteStreams . forEach ( remoteStream => remoteStream . unSubscribe ( ) ) ) ; return DataSync . set ( ` ${ this . uid } ${ uid } ` , WAS_CONNECTED ) . catch ( Log . r ( 'Room~leave' ) ) ; }
Leave the room.
Leave the room .
// Cancel onDisconnect // Disconnect user's callbacks // Unpublish all published local streams // Unsubscribe all remote streams // Update status // return DataSync.set(`_/rooms/${this.uid}/participants/${shortUserId}/status`, WAS_CONNECTED)