Skip to content

Af2NetStream.close

Petro O. Bochan edited this page Sep 2, 2023 · 2 revisions

Usage
myStream.close()

Description
Method; stops publishing or playing all data on the stream, and makes the stream available for another use. This method is invoked implicitly whenever you call Af2NetStream.play from a publishing stream, or Af2NetStream.publish from a subscribing stream.

  • If this method is called from a publishing stream, all pending Af2NetStream.play calls on the stream are cleared on the server; subscribers no longer receive anything that was being published on the stream.
  • If this method is called from a subscribing stream, publishing continues and other subscribing streams may still be playing, but the subscriber can now use the stream for another purpose.
  • To stop play on a subscribing stream without closing the stream or changing the stream type, use myStream.play(false).

Example
The following onDisconnect() function closes a stream.

private void onDisconnect() {
  // Stops publishing the stream.
  srcStream.close();
  // Deletes the source stream connection. With no source
  // to play, the destination stream also ends and can be
  // deleted.
  connection.close();
}

See also
Af2NetStream.play, Af2NetStream.publish

Clone this wiki locally