<p>Local connection to the Session. This object is defined only after <ahref="session.html#connect">Session.connect</a> has been successfully executed, and can be retrieved subscribing to <code>connectionCreated</code> event</p>
<p>Connects to the session using <code>token</code>. Parameter <code>metadata</code> allows you to pass extra data to share with other users when
they receive <code>streamCreated</code> event. The structure of <code>metadata</code> string is up to you (maybe some standarized format
as JSON or XML is a good idea), the only restriction is a maximum length of 10000 chars.</p>
</div>
<p>This metadata is not considered secure, as it is generated in the client side. To pass securized data, add it as a parameter in the
token generation operation (through the API REST, openvidu-java-client or openvidu-node-client).</p>
<p>Only after the returned Promise is successfully resolved <ahref="session.html#connection">Session.connection</a> object will be available and properly defined.</p>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="session.html">Session</a> object of the local participant will first dispatch one or more <code>connectionCreated</code> events upon successful termination of this method:</p>
<ul>
<li>First one for your own local Connection object, so you can retrieve <ahref="session.html#connection">Session.connection</a> property.</li>
<li>Then one for each remote Connection previously connected to the Session, if any. Any other remote user connecting to the Session after you have
successfully connected will also dispatch a <code>connectionCreated</code> event when they do so.</li>
</ul>
<p>The <ahref="session.html">Session</a> object of the local participant will also dispatch a <code>streamCreated</code> event for each remote active <ahref="publisher.html">Publisher</a> after dispatching all remote
<code>connectionCreated</code> events.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>connectionCreated</code> event.</p>
<p>See <ahref="connectionevent.html">ConnectionEvent</a> and <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<p>Connects to the session using <code>token</code>. Parameter <code>metadata</code> allows you to pass extra data to share with other users when
they receive <code>streamCreated</code> event. The structure of <code>metadata</code> string is up to you (maybe some standarized format
as JSON or XML is a good idea), the only restriction is a maximum length of 10000 chars.</p>
</div>
<p>This metadata is not considered secure, as it is generated in the client side. To pass securized data, add it as a parameter in the
token generation operation (through the API REST, openvidu-java-client or openvidu-node-client).</p>
<p>Only after the returned Promise is successfully resolved <ahref="session.html#connection">Session.connection</a> object will be available and properly defined.</p>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="session.html">Session</a> object of the local participant will first dispatch one or more <code>connectionCreated</code> events upon successful termination of this method:</p>
<ul>
<li>First one for your own local Connection object, so you can retrieve <ahref="session.html#connection">Session.connection</a> property.</li>
<li>Then one for each remote Connection previously connected to the Session, if any. Any other remote user connecting to the Session after you have
successfully connected will also dispatch a <code>connectionCreated</code> event when they do so.</li>
</ul>
<p>The <ahref="session.html">Session</a> object of the local participant will also dispatch a <code>streamCreated</code> event for each remote active <ahref="publisher.html">Publisher</a> after dispatching all remote
<code>connectionCreated</code> events.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>connectionCreated</code> event.</p>
<p>See <ahref="connectionevent.html">ConnectionEvent</a> and <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L166">OpenVidu/Session.ts:166</a></li>
<p>Leaves the session, destroying all streams and deleting the user as a participant.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="session.html">Session</a> object of the local participant will dispatch a <code>sessionDisconnected</code> event.
This event will automatically unsubscribe the leaving participant from every Subscriber object of the session (this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks)
and also delete the HTML video element associated to it.
Call <code>event.preventDefault()</code> to avoid this beahviour and take care of disposing and cleaning all the Subscriber objects yourself. See <ahref="sessiondisconnectedevent.html">SessionDisconnectedEvent</a> to learn more.</p>
<p>The <ahref="publisher.html">Publisher</a> object of the local participant will dispatch a <code>streamDestroyed</code> event if there is a <ahref="publisher.html">Publisher</a> object publishing to the session.
This event will automatically stop all media tracks and delete the HTML video element associated to it.
Call <code>event.preventDefault()</code> if you want clean the Publisher object yourself or re-publish it in a different Session (to do so it is a mandatory
requirement to call <code>Session.unpublish()</code> or/and <code>Session.disconnect()</code> in the previous session). See <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>streamDestroyed</code> event if the disconnected participant was publishing.
This event will automatically unsubscribe the Subscriber object from the session (this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks)
and delete the HTML video element associated to it.
Call <code>event.preventDefault()</code> to avoid this default behaviour and take care of disposing and cleaning the Subscriber object yourself. See <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>connectionDestroyed</code> event in any case. See <ahref="connectionevent.html">ConnectionEvent</a> to learn more.</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L494">OpenVidu/Session.ts:494</a></li>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L436">OpenVidu/Session.ts:436</a></li>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L465">OpenVidu/Session.ts:465</a></li>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L305">OpenVidu/Session.ts:305</a></li>
<p>Publishes the participant's audio-video stream contained in <code>publisher</code> object to the session</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The local <ahref="publisher.html">Publisher</a> object will dispatch a <code>streamCreated</code> event upon successful termination of this method. See <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<p>The local <ahref="publisher.html">Publisher</a> object will dispatch a <code>remoteVideoPlaying</code> event only if <ahref="publisher.html#subscribetoremote">Publisher.subscribeToRemote</a> was called before this method, once the remote video starts playing.
See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>streamCreated</code> event so they can subscribe to it. See <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<p>A Promise (to which you can optionally subscribe to) that is resolved if the publisher was successfully published and rejected with an Error object if not</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L400">OpenVidu/Session.ts:400</a></li>
<p>All users subscribed to that signal (<code>session.on('signal:type', ...)</code> or <code>session.on('signal', ...)</code> for all signals) and whose Connection objects are in <code>to</code> array will receive it. Their local
Session objects will dispatch a <code>signal</code> or <code>signal:type</code> event. See <ahref="signalevent.html">SignalEvent</a> to learn more.</p>
<p>A Promise (to which you can optionally subscribe to) that is resolved if the message successfully reached openvidu-server and rejected with an Error object if not. <em>This doesn't
mean that openvidu-server could resend the message to all the listed receivers.</em></p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L170">OpenVidu/Session.ts:170</a></li>
<p>Subscribes to a <code>stream</code>, adding a new HTML video element to DOM with <code>subscriberProperties</code> settings. This method is usually called in the callback of <code>streamCreated</code> event.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoElementCreated</code> event once the HTML video element has been added to DOM (if <em>targetElement</em> not null or undefined)</p>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoPlaying</code> event once the remote video starts playing (only if <code>videoElementCreated</code> event has been previously dispatched)</p>
<p>See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more.</p>
<p>HTML DOM element (or its <code>id</code> attribute) in which the video element of the Subscriber will be inserted (see <ahref="../interfaces/subscriberproperties.html#insertmode">SubscriberProperties.insertMode</a>). If null or undefined no default video will be created for this Subscriber
(you can always access the native MediaStream object by calling <em>Subscriber.stream.getMediaStream()</em> and use it as <em>srcObject</em> of any HTML video element)</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L171">OpenVidu/Session.ts:171</a></li>
<p>Subscribes to a <code>stream</code>, adding a new HTML video element to DOM with <code>subscriberProperties</code> settings. This method is usually called in the callback of <code>streamCreated</code> event.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoElementCreated</code> event once the HTML video element has been added to DOM (if <em>targetElement</em> not null or undefined)</p>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoPlaying</code> event once the remote video starts playing (only if <code>videoElementCreated</code> event has been previously dispatched)</p>
<p>See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more.</p>
<p>HTML DOM element (or its <code>id</code> attribute) in which the video element of the Subscriber will be inserted (see <ahref="../interfaces/subscriberproperties.html#insertmode">SubscriberProperties.insertMode</a>). If null or undefined no default video will be created for this Subscriber
(you can always access the native MediaStream object by calling <em>Subscriber.stream.getMediaStream()</em> and use it as <em>srcObject</em> of any HTML video element)</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L172">OpenVidu/Session.ts:172</a></li>
<p>Subscribes to a <code>stream</code>, adding a new HTML video element to DOM with <code>subscriberProperties</code> settings. This method is usually called in the callback of <code>streamCreated</code> event.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoElementCreated</code> event once the HTML video element has been added to DOM (if <em>targetElement</em> not null or undefined)</p>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoPlaying</code> event once the remote video starts playing (only if <code>videoElementCreated</code> event has been previously dispatched)</p>
<p>See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more.</p>
<p>HTML DOM element (or its <code>id</code> attribute) in which the video element of the Subscriber will be inserted (see <ahref="../interfaces/subscriberproperties.html#insertmode">SubscriberProperties.insertMode</a>). If null or undefined no default video will be created for this Subscriber
(you can always access the native MediaStream object by calling <em>Subscriber.stream.getMediaStream()</em> and use it as <em>srcObject</em> of any HTML video element)</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L173">OpenVidu/Session.ts:173</a></li>
<p>Subscribes to a <code>stream</code>, adding a new HTML video element to DOM with <code>subscriberProperties</code> settings. This method is usually called in the callback of <code>streamCreated</code> event.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoElementCreated</code> event once the HTML video element has been added to DOM (if <em>targetElement</em> not null or undefined)</p>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoPlaying</code> event once the remote video starts playing (only if <code>videoElementCreated</code> event has been previously dispatched)</p>
<p>See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more.</p>
<p>HTML DOM element (or its <code>id</code> attribute) in which the video element of the Subscriber will be inserted (see <ahref="../interfaces/subscriberproperties.html#insertmode">SubscriberProperties.insertMode</a>). If null or undefined no default video will be created for this Subscriber
(you can always access the native MediaStream object by calling <em>Subscriber.stream.getMediaStream()</em> and use it as <em>srcObject</em> of any HTML video element)</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L237">OpenVidu/Session.ts:237</a></li>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L238">OpenVidu/Session.ts:238</a></li>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L355">OpenVidu/Session.ts:355</a></li>
<p>Unpublishes the participant's audio-video stream contained in <code>publisher</code> object.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="publisher.html">Publisher</a> object of the local participant will dispatch a <code>streamDestroyed</code> event.
This event will automatically stop all media tracks and delete the HTML video element associated to it.
Call <code>event.preventDefault()</code> if you want clean the Publisher object yourself or re-publish it in a different Session.</p>
<p>The <ahref="session.html">Session</a> object of every other participant connected to the session will dispatch a <code>streamDestroyed</code> event.
This event will automatically unsubscribe the Subscriber object from the session (this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks) and delete the HTML video element associated to it.
Call <code>event.preventDefault()</code> to avoid this default behaviour and take care of disposing and cleaning the Subscriber object yourself.</p>
<p>See <ahref="streamevent.html">StreamEvent</a> to learn more.</p>
<li>Defined in <ahref="https://github.com/OpenVidu/openvidu/tree/master/openvidu-browser/src/OpenVidu/Session.ts#L270">OpenVidu/Session.ts:270</a></li>
<p>Unsubscribes from <code>subscriber</code>, automatically removing its HTML video element.</p>
</div>
<h4id="events-dispatched">Events dispatched</h4>
<p>The <ahref="subscriber.html">Subscriber</a> object will dispatch a <code>videoElementDestroyed</code> event (only if it previously dispatched a <code>videoElementCreated</code> event). See <ahref="videoelementevent.html">VideoElementEvent</a> to learn more</p>