Publishing a stream

Once you have a Publisher object and a session the next step is to pass it to the session object.

Pass the publisher object into the publish() method of a Session object to publish a stream to the session:

The second parameter is a completion handler function that is passed an error object if publishing fails. Otherwise the completion handler function is called with no error passed in.

This code assumes that session is a Session object, and that the client has connected to the session. For more information, see Joining a Session.

The Publish object dispatches a streamCreated event when it starts streaming to the session:

The Publisher object has an element property, which is set to the HTML DOM element containing it.