If User B wanted to cease publishing to the session, the
Session.unpublish() method would be used
as shown below:
User B unpublishes its stream; User A subsequently unsubscribes from User B's stream
Session.unpublish() method stops the specified publisher from
streaming and removes the local video display from the web page.
The session sends a
streamDestroyed event to all
connections. Assuming an event
listener is registered for this event, it will be invoked with a StreamEvent
object. This object includes an array of
that have been destroyed.
Usually, if a web page is
subscribing to a stream that gets destroyed, the web page will want to
unsubscribe from the stream. The
makes it easy to figure out which subscribers
to pass to
User A calls
Session.getSubscribersForStream(), passing it the
stream contained in the StreamEvent object received through the
streamDestroyed event listener. User A can then invoke
passing it the
subscriber returned from the previous call. Calling the
method removes the video display associated with the specified subscriber's stream from the local web page.
Note that User B's web page is also notified of the destruction of the stream
they just ceased publishing. Once
again, User B's web page can know that a
references its own previously published stream by comparing the
stream.connection.connectionId from the
StreamEvent streams array to its own
in most cases, User B's web page will choose to ignore the notification.
Next workflow step: Disconnect from a session.