File: source/skylink-events.js

  1. var _eventsDocs = {
  2. /**
  3. * Event triggered when socket connection to Signaling server has opened.
  4. * @event channelOpen
  5. * @param {JSON} session The socket connection session information.
  6. * @param {String} session.serverUrl The socket connection Signaling url used.
  7. * @param {String} session.transportType The socket connection transport type used.
  8. * @param {JSON} session.socketOptions The socket connection options.
  9. * @param {Number} session.attempts The socket connection current reconnection attempts.
  10. * @param {Number} session.finalAttempts The socket connection current last attempts
  11. * for the last available transports and port.
  12. * @for Skylink
  13. * @since 0.1.0
  14. */
  15. channelOpen: [],
  16.  
  17. /**
  18. * Event triggered when socket connection to Signaling server has closed.
  19. * @event channelClose
  20. * @param {JSON} session The socket connection session information.
  21. * <small>Object signature matches the <code>session</code> parameter payload received in the
  22. * <a href="#event_channelOpen"><code>channelOpen</code> event</a>.</small>
  23. * @for Skylink
  24. * @since 0.1.0
  25. */
  26. channelClose: [],
  27.  
  28. /**
  29. * <blockquote class="info">
  30. * Note that this is used only for SDK developer purposes.
  31. * </blockquote>
  32. * Event triggered when receiving socket message from the Signaling server.
  33. * @event channelMessage
  34. * @param {JSON} message The socket message object.
  35. * @param {JSON} session The socket connection session information.
  36. * <small>Object signature matches the <code>session</code> parameter payload received in the
  37. * <a href="#event_channelOpen"><code>channelOpen</code> event</a>.</small>
  38. * @for Skylink
  39. * @since 0.1.0
  40. */
  41. channelMessage: [],
  42.  
  43. /**
  44. * <blockquote class="info">
  45. * This may be caused by Javascript errors in the event listener when subscribing to events.<br>
  46. * It may be resolved by checking for code errors in your Web App in the event subscribing listener.<br>
  47. * <code>skylinkDemo.on("eventName", function () { // Errors here });</code>
  48. * </blockquote>
  49. * Event triggered when socket connection encountered exception.
  50. * @event channelError
  51. * @param {Error|String} error The error object.
  52. * @param {JSON} session The socket connection session information.
  53. * <small>Object signature matches the <code>session</code> parameter payload received in the
  54. * <a href="#event_channelOpen"><code>channelOpen</code> event</a>.</small>
  55. * @for Skylink
  56. * @since 0.1.0
  57. */
  58. channelError: [],
  59.  
  60. /**
  61. * Event triggered when attempting to establish socket connection to Signaling server when failed.
  62. * @event channelRetry
  63. * @param {String} fallbackType The current fallback state.
  64. * [Rel: Skylink.SOCKET_FALLBACK]
  65. * @param {Number} currentAttempt The current socket reconnection attempt.
  66. * @param {JSON} session The socket connection session information.
  67. * <small>Object signature matches the <code>session</code> parameter payload received in the
  68. * <a href="#event_channelOpen"><code>channelOpen</code> event</a>.</small>
  69. * @for Skylink
  70. * @since 0.5.6
  71. */
  72. channelRetry: [],
  73.  
  74. /**
  75. * Event triggered when attempt to establish socket connection to Signaling server has failed.
  76. * @event socketError
  77. * @param {Number} errorCode The socket connection error code.
  78. * [Rel: Skylink.SOCKET_ERROR]
  79. * @param {Error|String|Number} error The error object.
  80. * @param {String} type The fallback state of the socket connection attempt.
  81. * [Rel: Skylink.SOCKET_FALLBACK]
  82. * @param {JSON} session The socket connection session information.
  83. * <small>Object signature matches the <code>session</code> parameter payload received in the
  84. * <a href="#event_channelOpen"><code>channelOpen</code> event</a>.</small>
  85. * @for Skylink
  86. * @since 0.5.5
  87. */
  88. socketError: [],
  89.  
  90. /**
  91. * Event triggered when <a href="#method_init"><code>init()</code> method</a> ready state changes.
  92. * @event readyStateChange
  93. * @param {Number} readyState The current <code>init()</code> ready state.
  94. * [Rel: Skylink.READY_STATE_CHANGE]
  95. * @param {JSON} [error] The error result.
  96. * <small>Defined only when <code>state</code> is <code>ERROR</code>.</small>
  97. * @param {Number} error.status The HTTP status code when failed.
  98. * @param {Number} error.errorCode The ready state change failure code.
  99. * [Rel: Skylink.READY_STATE_CHANGE_ERROR]
  100. * @param {Error} error.content The error object.
  101. * @param {String} room The Room to The Room to retrieve session token for.
  102. * @for Skylink
  103. * @since 0.4.0
  104. */
  105. readyStateChange: [],
  106.  
  107. /**
  108. * Event triggered when a Peer connection establishment state has changed.
  109. * @event handshakeProgress
  110. * @param {String} state The current Peer connection establishment state.
  111. * [Rel: Skylink.HANDSHAKE_PROGRESS]
  112. * @param {String} peerId The Peer ID.
  113. * @param {Error|String} [error] The error object.
  114. * <small>Defined only when <code>state</code> is <code>ERROR</code>.</small>
  115. * @for Skylink
  116. * @since 0.3.0
  117. */
  118. handshakeProgress: [],
  119.  
  120. /**
  121. * <blockquote class="info">
  122. * Learn more about how ICE works in this
  123. * <a href="https://temasys.com.sg/ice-what-is-this-sorcery/">article here</a>.
  124. * </blockquote>
  125. * Event triggered when a Peer connection ICE gathering state has changed.
  126. * @event candidateGenerationState
  127. * @param {String} state The current Peer connection ICE gathering state.
  128. * [Rel: Skylink.CANDIDATE_GENERATION_STATE]
  129. * @param {String} peerId The Peer ID.
  130. * @for Skylink
  131. * @since 0.1.0
  132. */
  133. candidateGenerationState: [],
  134.  
  135. /**
  136. * <blockquote class="info">
  137. * Learn more about how ICE works in this
  138. * <a href="https://temasys.com.sg/ice-what-is-this-sorcery/">article here</a>.
  139. * </blockquote>
  140. * Event triggered when a Peer connection session description exchanging state has changed.
  141. * @event peerConnectionState
  142. * @param {String} state The current Peer connection session description exchanging state.
  143. * [Rel: Skylink.PEER_CONNECTION_STATE]
  144. * @param {String} peerId The Peer ID.
  145. * @for Skylink
  146. * @since 0.1.0
  147. */
  148. peerConnectionState: [],
  149.  
  150. /**
  151. * <blockquote class="info">
  152. * Learn more about how ICE works in this
  153. * <a href="https://temasys.com.sg/ice-what-is-this-sorcery/">article here</a>.
  154. * </blockquote>
  155. * Event triggered when a Peer connection ICE connection state has changed.
  156. * @event iceConnectionState
  157. * @param {String} state The current Peer connection ICE connection state.
  158. * [Rel: Skylink.ICE_CONNECTION_STATE]
  159. * @param {String} peerId The Peer ID.
  160. * @for Skylink
  161. * @since 0.1.0
  162. */
  163. iceConnectionState: [],
  164.  
  165. /**
  166. * Event triggered when retrieval of Stream failed.
  167. * @event mediaAccessError
  168. * @param {Error|String} error The error object.
  169. * @param {Boolean} isScreensharing The flag if event occurred during
  170. * <a href="#method_shareScreen"><code>shareScreen()</code> method</a> and not
  171. * <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>.
  172. * @param {Boolean} isAudioFallbackError The flag if event occurred during
  173. * retrieval of audio tracks only when <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>
  174. * had failed to retrieve both audio and video tracks.
  175. * @for Skylink
  176. * @since 0.1.0
  177. */
  178. mediaAccessError: [],
  179.  
  180. /**
  181. * Event triggered when Stream retrieval fallback state has changed.
  182. * @event mediaAccessFallback
  183. * @param {JSON} error The error result.
  184. * @param {Error|String} error.error The error object.
  185. * @param {JSON} [error.diff=null] The list of excepted but received audio and video tracks in Stream.
  186. * <small>Defined only when <code>state</code> payload is <code>FALLBACKED</code>.</small>
  187. * @param {JSON} error.diff.video The expected and received video tracks.
  188. * @param {Number} error.diff.video.expected The expected video tracks.
  189. * @param {Number} error.diff.video.received The received video tracks.
  190. * @param {JSON} error.diff.audio The expected and received audio tracks.
  191. * @param {Number} error.diff.audio.expected The expected audio tracks.
  192. * @param {Number} error.diff.audio.received The received audio tracks.
  193. * @param {Number} state The fallback state.
  194. * [Rel: Skylink.MEDIA_ACCESS_FALLBACK_STATE]
  195. * @param {Boolean} isScreensharing The flag if event occurred during
  196. * <a href="#method_shareScreen"><code>shareScreen()</code> method</a> and not
  197. * <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>.
  198. * @param {Boolean} isAudioFallback The flag if event occurred during
  199. * retrieval of audio tracks only when <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>
  200. * had failed to retrieve both audio and video tracks.
  201. * @param {String} streamId The Stream ID.
  202. * <small>Defined only when <code>state</code> payload is <code>FALLBACKED</code>.</small>
  203. * @for Skylink
  204. * @since 0.6.3
  205. */
  206. mediaAccessFallback: [],
  207.  
  208. /**
  209. * Event triggered when retrieval of Stream is successful.
  210. * @event mediaAccessSuccess
  211. * @param {MediaStream} stream The Stream object.
  212. * <small>To attach it to an element: <code>attachMediaStream(videoElement, stream);</code>.</small>
  213. * @param {Boolean} isScreensharing The flag if event occurred during
  214. * <a href="#method_shareScreen"><code>shareScreen()</code> method</a> and not
  215. * <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>.
  216. * @param {Boolean} isAudioFallback The flag if event occurred during
  217. * retrieval of audio tracks only when <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>
  218. * had failed to retrieve both audio and video tracks.
  219. * @param {String} streamId The Stream ID.
  220. * @for Skylink
  221. * @since 0.1.0
  222. */
  223. mediaAccessSuccess: [],
  224.  
  225. /**
  226. * Event triggered when retrieval of Stream is required to complete <a href="#method_joinRoom">
  227. * <code>joinRoom()</code> method</a> request.
  228. * @event mediaAccessRequired
  229. * @for Skylink
  230. * @since 0.5.5
  231. */
  232. mediaAccessRequired: [],
  233.  
  234. /**
  235. * Event triggered when Stream has stopped streaming.
  236. * @event mediaAccessStopped
  237. * @param {Boolean} isScreensharing The flag if event occurred during
  238. * <a href="#method_shareScreen"><code>shareScreen()</code> method</a> and not
  239. * <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>.
  240. * @param {Boolean} isAudioFallback The flag if event occurred during
  241. * retrieval of audio tracks only when <a href="#method_getUserMedia"><code>getUserMedia()</code> method</a>
  242. * had failed to retrieve both audio and video tracks.
  243. * @param {String} streamId The Stream ID.
  244. * @for Skylink
  245. * @since 0.5.6
  246. */
  247. mediaAccessStopped: [],
  248.  
  249. /**
  250. * Event triggered when a Peer joins the room.
  251. * @event peerJoined
  252. * @param {String} peerId The Peer ID.
  253. * @param {JSON} peerInfo The Peer session information.
  254. * @param {JSON|String} peerInfo.userData The Peer current custom data.
  255. * @param {JSON} peerInfo.settings The Peer sending Stream settings.
  256. * @param {Boolean|JSON} peerInfo.settings.data The flag if Peer has any Datachannel connections enabled.
  257. * <small>If <code>isSelf</code> value is <code>true</code>, this determines if User allows
  258. * Datachannel connections, else if value is <code>false</code>, this determines if Peer has any active
  259. * Datachannel connections (where <a href="#event_dataChannelState"><code>dataChannelState</code> event</a>
  260. * triggers <code>state</code> as <code>OPEN</code> and <code>channelType</code> as
  261. * <code>MESSAGING</code> for Peer) with Peer.</small>
  262. * @param {Boolean|JSON} peerInfo.settings.audio The Peer Stream audio settings.
  263. * <small>When defined as <code>false</code>, it means there is no audio being sent from Peer.</small>
  264. * <small>When defined as <code>true</code>, the <code>peerInfo.settings.audio.stereo</code> value is
  265. * considered as <code>false</code> and the <code>peerInfo.settings.audio.exactConstraints</code>
  266. * value is considered as <code>false</code>.</small>
  267. * @param {Boolean} peerInfo.settings.audio.stereo The flag if stereo band is configured
  268. * when encoding audio codec is <a href="#attr_AUDIO_CODEC"><code>OPUS</code></a> for receiving audio data.
  269. * @param {Boolean} [peerInfo.settings.audio.usedtx] <blockquote class="info">
  270. * Note that this feature might not work depending on the browser support and implementation.</blockquote>
  271. * The flag if DTX (Discontinuous Transmission) is configured when encoding audio codec
  272. * is <a href="#attr_AUDIO_CODEC"><code>OPUS</code></a> for sending audio data.
  273. * <small>This might help to reduce bandwidth it reduces the bitrate during silence or background noise.</small>
  274. * <small>When not defined, the default browser configuration is used.</small>
  275. * @param {Boolean} [peerInfo.settings.audio.useinbandfec] <blockquote class="info">
  276. * Note that this feature might not work depending on the browser support and implementation.</blockquote>
  277. * The flag if capability to take advantage of in-band FEC (Forward Error Correction) is
  278. * configured when encoding audio codec is <a href="#attr_AUDIO_CODEC"><code>OPUS</code></a> for sending audio data.
  279. * <small>This might help to reduce the harm of packet loss by encoding information about the previous packet.</small>
  280. * <small>When not defined, the default browser configuration is used.</small>
  281. * @param {Number} [peerInfo.settings.audio.maxplaybackrate] <blockquote class="info">
  282. * Note that this feature might not work depending on the browser support and implementation.</blockquote>
  283. * The maximum output sampling rate rendered in Hertz (Hz) when encoding audio codec is
  284. * <a href="#attr_AUDIO_CODEC"><code>OPUS</code></a> for sending audio data.
  285. * <small>This value must be between <code>8000</code> to <code>48000</code>.</small>
  286. * <small>When not defined, the default browser configuration is used.</small>
  287. * @param {Boolean} peerInfo.settings.audio.echoCancellation The flag if echo cancellation is enabled for audio tracks.
  288. * @param {Array} [peerInfo.settings.audio.optional] The Peer Stream <code>navigator.getUserMedia()</code> API
  289. * <code>audio: { optional [..] }</code> property.
  290. * @param {String} [peerInfo.settings.audio.deviceId] The Peer Stream audio track source ID of the device used.
  291. * @param {Boolean} peerInfo.settings.audio.exactConstraints The flag if Peer Stream audio track is sending exact
  292. * requested values of <code>peerInfo.settings.audio.deviceId</code> when provided.
  293. * @param {Boolean|JSON} peerInfo.settings.video The Peer Stream video settings.
  294. * <small>When defined as <code>false</code>, it means there is no video being sent from Peer.</small>
  295. * <small>When defined as <code>true</code>, the <code>peerInfo.settings.video.screenshare</code> value is
  296. * considered as <code>false</code> and the <code>peerInfo.settings.video.exactConstraints</code>
  297. * value is considered as <code>false</code>.</small>
  298. * @param {JSON} [peerInfo.settings.video.resolution] The Peer Stream video resolution.
  299. * [Rel: Skylink.VIDEO_RESOLUTION]
  300. * @param {Number|JSON} peerInfo.settings.video.resolution.width The Peer Stream video resolution width or
  301. * video resolution width settings.
  302. * <small>When defined as a JSON object, it is the user set resolution width settings with (<code>"min"</code> or
  303. * <code>"max"</code> or <code>"ideal"</code> or <code>"exact"</code> etc configurations).</small>
  304. * @param {Number|JSON} peerInfo.settings.video.resolution.height The Peer Stream video resolution height or
  305. * video resolution height settings.
  306. * <small>When defined as a JSON object, it is the user set resolution height settings with (<code>"min"</code> or
  307. * <code>"max"</code> or <code>"ideal"</code> or <code>"exact"</code> etc configurations).</small>
  308. * @param {Number|JSON} [peerInfo.settings.video.frameRate] The Peer Stream video
  309. * <a href="https://en.wikipedia.org/wiki/Frame_rate">frameRate</a> per second (fps) or video frameRate settings.
  310. * <small>When defined as a JSON object, it is the user set frameRate settings with (<code>"min"</code> or
  311. * <code>"max"</code> or <code>"ideal"</code> or <code>"exact"</code> etc configurations).</small>
  312. * @param {Boolean} peerInfo.settings.video.screenshare The flag if Peer Stream is a screensharing Stream.
  313. * @param {Array} [peerInfo.settings.video.optional] The Peer Stream <code>navigator.getUserMedia()</code> API
  314. * <code>video: { optional [..] }</code> property.
  315. * @param {String} [peerInfo.settings.video.deviceId] The Peer Stream video track source ID of the device used.
  316. * @param {Boolean} peerInfo.settings.video.exactConstraints The flag if Peer Stream video track is sending exact
  317. * requested values of <code>peerInfo.settings.video.resolution</code>,
  318. * <code>peerInfo.settings.video.frameRate</code> and <code>peerInfo.settings.video.deviceId</code>
  319. * when provided.
  320. * @param {String|JSON} [peerInfo.settings.video.facingMode] The Peer Stream video camera facing mode.
  321. * <small>When defined as a JSON object, it is the user set facingMode settings with (<code>"min"</code> or
  322. * <code>"max"</code> or <code>"ideal"</code> or <code>"exact"</code> etc configurations).</small>
  323. * @param {JSON} peerInfo.settings.bandwidth The maximum streaming bandwidth sent from Peer.
  324. * @param {Number} [peerInfo.settings.bandwidth.audio] The maximum audio streaming bandwidth sent from Peer.
  325. * @param {Number} [peerInfo.settings.bandwidth.video] The maximum video streaming bandwidth sent from Peer.
  326. * @param {Number} [peerInfo.settings.bandwidth.data] The maximum data streaming bandwidth sent from Peer.
  327. * @param {JSON} peerInfo.settings.googleXBandwidth <blockquote class="info">
  328. * Note that this feature might not work depending on the browser support and implementation,
  329. * and its properties and values are only defined for User's end and cannot be viewed
  330. * from Peer's end (when <code>isSelf</code> value is <code>false</code>).</blockquote>
  331. * The experimental google video streaming bandwidth sent to Peers.
  332. * @param {Number} [peerInfo.settings.googleXBandwidth.min] The minimum experimental google video streaming bandwidth sent to Peers.
  333. * @param {Number} [peerInfo.settings.googleXBandwidth.max] The maximum experimental google video streaming bandwidth sent to Peers.
  334. * @param {JSON} peerInfo.mediaStatus The Peer Stream muted settings.
  335. * @param {Boolean} peerInfo.mediaStatus.audioMuted The flag if Peer Stream audio tracks is muted or not.
  336. * <small>If Peer <code>peerInfo.settings.audio</code> is false, this will be defined as <code>true</code>.</small>
  337. * @param {Boolean} peerInfo.mediaStatus.videoMuted The flag if Peer Stream video tracks is muted or not.
  338. * <small>If Peer <code>peerInfo.settings.video</code> is false, this will be defined as <code>true</code>.</small>
  339. * @param {JSON} peerInfo.agent The Peer agent information.
  340. * @param {String} peerInfo.agent.name The Peer agent name.
  341. * <small>Data may be accessing browser or non-Web SDK name.</small>
  342. * @param {Number} peerInfo.agent.version The Peer agent version.
  343. * <small>Data may be accessing browser or non-Web SDK version. If the original value is <code>"0.9.6.1"</code>,
  344. * it will be interpreted as <code>0.90601</code> where <code>0</code> helps to seperate the minor dots.</small>
  345. * @param {String} [peerInfo.agent.os] The Peer platform name.
  346. * <small>Data may be accessing OS platform version from Web SDK.</small>
  347. * @param {String} [peerInfo.agent.pluginVersion] The Peer Temasys Plugin version.
  348. * <small>Defined only when Peer is using the Temasys Plugin (IE / Safari).</small>
  349. * @param {String} peerInfo.agent.DTProtocolVersion The Peer data transfer (DT) protocol version.
  350. * @param {String} peerInfo.agent.SMProtocolVersion The Peer signaling message (SM) protocol version.
  351. * @param {String} peerInfo.room The Room Peer is from.
  352. * @param {JSON} peerInfo.config The Peer connection configuration.
  353. * @param {Boolean} peerInfo.config.enableIceTrickle The flag if Peer connection has
  354. * trickle ICE enabled or faster connectivity.
  355. * @param {Boolean} peerInfo.config.enableDataChannel The flag if Datachannel connections would be enabled for Peer.
  356. * @param {Boolean} peerInfo.config.enableIceRestart The flag if Peer connection has ICE connection restart support.
  357. * <small>Note that ICE connection restart support is not honoured for MCU enabled Peer connection.</small>
  358. * @param {Number} peerInfo.config.priorityWeight The flag if Peer or User should be the offerer.
  359. * <small>If User's <code>priorityWeight</code> is higher than Peer's, User is the offerer, else Peer is.
  360. * However for the case where the MCU is connected, User will always be the offerer.</small>
  361. * @param {Boolean} peerInfo.config.publishOnly The flag if Peer is publishing only stream but not receiving streams.
  362. * @param {Boolean} peerInfo.config.receiveOnly The flag if Peer is receiving only streams but not publishing stream.
  363. * @param {String} [peerInfo.parentId] The parent Peer ID that it is matched to for multi-streaming connections.
  364. * @param {Boolean} [peerInfo.connected] The flag if Peer ICE connection has been established successfully.
  365. * <small>Defined only when <code>isSelf</code> payload value is <code>false</code>.</small>
  366. * @param {Boolean} [peerInfo.init] The flag if Peer connection has been created successfully.
  367. * <small>Defined only when <code>isSelf</code> payload value is <code>false</code>.</small>
  368. * @param {Boolean} isSelf The flag if Peer is User.
  369. * @for Skylink
  370. * @since 0.5.2
  371. */
  372. peerJoined: [],
  373.  
  374. /**
  375. * Event triggered when a Peer connection has been refreshed.
  376. * @event peerRestart
  377. * @param {String} peerId The Peer ID.
  378. * @param {JSON} peerInfo The Peer session information.
  379. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  380. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  381. * @param {Boolean} isSelfInitiateRestart The flag if User is initiating the Peer connection refresh.
  382. * @param {Boolean} isIceRestart The flag if Peer connection ICE connection will restart.
  383. * @for Skylink
  384. * @since 0.5.5
  385. */
  386. peerRestart: [],
  387.  
  388. /**
  389. * Event triggered when a Peer session information has been updated.
  390. * @event peerUpdated
  391. * @param {String} peerId The Peer ID.
  392. * @param {JSON} peerInfo The Peer session information.
  393. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  394. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  395. * @param {Boolean} isSelf The flag if Peer is User.
  396. * @for Skylink
  397. * @since 0.5.2
  398. */
  399. peerUpdated: [],
  400.  
  401. /**
  402. * Event triggered when a Peer leaves the room.
  403. * @event peerLeft
  404. * @param {String} peerId The Peer ID.
  405. * @param {JSON} peerInfo The Peer session information.
  406. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  407. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  408. * @param {Boolean} isSelf The flag if Peer is User.
  409. * @for Skylink
  410. * @since 0.5.2
  411. */
  412. peerLeft: [],
  413.  
  414. /**
  415. * Event triggered when Room session has ended abruptly due to network disconnections.
  416. * @event sessionDisconnect
  417. * @param {String} peerId The User's Room session Peer ID.
  418. * @param {JSON} peerInfo The User's Room session information.
  419. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  420. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  421. * @for Skylink
  422. * @since 0.6.10
  423. */
  424. sessionDisconnect: [],
  425.  
  426. /**
  427. * Event triggered when receiving Peer Stream.
  428. * @event incomingStream
  429. * @param {String} peerId The Peer ID.
  430. * @param {MediaStream} stream The Stream object.
  431. * <small>To attach it to an element: <code>attachMediaStream(videoElement, stream);</code>.</small>
  432. * @param {Boolean} isSelf The flag if Peer is User.
  433. * @param {JSON} peerInfo The Peer session information.
  434. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  435. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  436. * @param {Boolean} isScreensharing The flag if Peer Stream is a screensharing Stream.
  437. * @param {String} streamId The Stream ID.
  438. * @for Skylink
  439. * @since 0.5.5
  440. */
  441. incomingStream: [],
  442.  
  443. /**
  444. * Event triggered when receiving message from Peer.
  445. * @event incomingMessage
  446. * @param {JSON} message The message result.
  447. * @param {JSON|String} message.content The message object.
  448. * @param {String} message.senderPeerId The sender Peer ID.
  449. * @param {String|Array} [message.targetPeerId] The value of the <code>targetPeerId</code>
  450. * defined in <a href="#method_sendP2PMessage"><code>sendP2PMessage()</code> method</a> or
  451. * <a href="#method_sendMessage"><code>sendMessage()</code> method</a>.
  452. * <small>Defined as User's Peer ID when <code>isSelf</code> payload value is <code>false</code>.</small>
  453. * <small>Defined as <code>null</code> when provided <code>targetPeerId</code> in
  454. * <a href="#method_sendP2PMessage"><code>sendP2PMessage()</code> method</a> or
  455. * <a href="#method_sendMessage"><code>sendMessage()</code> method</a> is not defined.</small>
  456. * @param {Array} [message.listOfPeers] The list of Peers that the message has been sent to.
  457. * <small>Defined only when <code>isSelf</code> payload value is <code>true</code>.</small>
  458. * @param {Boolean} message.isPrivate The flag if message is targeted or not, basing
  459. * off the <code>targetPeerId</code> parameter being defined in
  460. * <a href="#method_sendP2PMessage"><code>sendP2PMessage()</code> method</a> or
  461. * <a href="#method_sendMessage"><code>sendMessage()</code> method</a>.
  462. * @param {Boolean} message.isDataChannel The flag if message is sent from
  463. * <a href="#method_sendP2PMessage"><code>sendP2PMessage()</code> method</a>.
  464. * @param {String} peerId The Peer ID.
  465. * @param {JSON} peerInfo The Peer session information.
  466. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  467. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  468. * @param {Boolean} isSelf The flag if Peer is User.
  469. * @for Skylink
  470. * @since 0.5.2
  471. */
  472. incomingMessage: [],
  473.  
  474. /**
  475. * Event triggered when receiving completed data transfer from Peer.
  476. * @event incomingData
  477. * @param {Blob|String} data The data.
  478. * @param {String} transferId The data transfer ID.
  479. * @param {String} peerId The Peer ID.
  480. * @param {JSON} transferInfo The data transfer information.
  481. * <small>Object signature matches the <code>transferInfo</code> parameter payload received in the
  482. * <a href="#event_dataTransferState"><code>dataTransferState</code> event</a>
  483. * except without the <code>data</code> property.</small>
  484. * @param {Boolean} isSelf The flag if Peer is User.
  485. * @for Skylink
  486. * @since 0.6.1
  487. */
  488. incomingData: [],
  489.  
  490. /**
  491. * Event triggered when receiving upload data transfer from Peer.
  492. * @event incomingDataRequest
  493. * @param {String} transferId The transfer ID.
  494. * @param {String} peerId The Peer ID.
  495. * @param {String} transferInfo The data transfer information.
  496. * <small>Object signature matches the <code>transferInfo</code> parameter payload received in the
  497. * <a href="#event_dataTransferState"><code>dataTransferState</code> event</a>
  498. * except without the <code>data</code> property.</small>
  499. * @param {Boolean} isSelf The flag if Peer is User.
  500. * @for Skylink
  501. * @since 0.6.1
  502. */
  503. incomingDataRequest: [],
  504.  
  505. /**
  506. * Event triggered when data streaming session has been started from Peer to User.
  507. * @event incomingDataStreamStarted
  508. * @param {String} streamId The data streaming session ID.
  509. * @param {String} peerId The Peer ID.
  510. * @param {JSON} streamInfo The data streaming session information.
  511. * <small>Object signature matches the <code>streamInfo</code> parameter payload received in the
  512. * <a href="#event_dataStreamState"><code>dataStreamState</code> event</a>
  513. * except without the <code>chunk</code> property.</small>
  514. * @param {Boolean} isSelf The flag if Peer is User.
  515. * @beta
  516. * @for Skylink
  517. * @since 0.6.18
  518. */
  519. incomingDataStreamStarted: [],
  520.  
  521. /**
  522. * Event triggered when data streaming session has been stopped from Peer to User.
  523. * @event incomingDataStreamStopped
  524. * @param {String} streamId The data streaming session ID.
  525. * @param {String} peerId The Peer ID.
  526. * @param {JSON} streamInfo The data streaming session information.
  527. * <small>Object signature matches the <code>streamInfo</code> parameter payload received in the
  528. * <a href="#event_dataStreamState"><code>dataStreamState</code> event</a>
  529. * except without the <code>chunk</code> property.</small>
  530. * @param {Boolean} isSelf The flag if Peer is User.
  531. * @beta
  532. * @for Skylink
  533. * @since 0.6.18
  534. */
  535. incomingDataStreamStopped: [],
  536.  
  537. /**
  538. * Event triggered when data streaming session has been stopped from Peer to User.
  539. * @event incomingDataStream
  540. * @param {Blob|String} chunk The data chunk received.
  541. * @param {String} streamId The data streaming session ID.
  542. * @param {String} peerId The Peer ID.
  543. * @param {JSON} streamInfo The data streaming session information.
  544. * <small>Object signature matches the <code>streamInfo</code> parameter payload received in the
  545. * <a href="#event_dataStreamState"><code>dataStreamState</code> event</a>
  546. * except without the <code>chunk</code> property.</small>
  547. * @param {Boolean} isSelf The flag if Peer is User.
  548. * @beta
  549. * @for Skylink
  550. * @since 0.6.18
  551. */
  552. incomingDataStream: [],
  553.  
  554. /**
  555. * Event triggered when Room locked status has changed.
  556. * @event roomLock
  557. * @param {Boolean} isLocked The flag if Room is locked.
  558. * @param {String} peerId The Peer ID.
  559. * @param {JSON} peerInfo The Peer session information.
  560. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  561. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  562. * @param {Boolean} isSelf The flag if User changed the Room locked status.
  563. * @for Skylink
  564. * @since 0.5.2
  565. */
  566. roomLock: [],
  567.  
  568. /**
  569. * Event triggered when a Datachannel connection state has changed.
  570. * @event dataChannelState
  571. * @param {String} state The current Datachannel connection state.
  572. * [Rel: Skylink.DATA_CHANNEL_STATE]
  573. * @param {String} peerId The Peer ID.
  574. * @param {Error} [error] The error object.
  575. * <small>Defined only when <code>state</code> payload is <code>ERROR</code> or <code>SEND_MESSAGE_ERROR</code>.</small>
  576. * @param {String} channelName The Datachannel ID.
  577. * @param {String} channelType The Datachannel type.
  578. * [Rel: Skylink.DATA_CHANNEL_TYPE]
  579. * @param {String} messageType The Datachannel sending Datachannel message error type.
  580. * <small>Defined only when <cod>state</code> payload is <code>SEND_MESSAGE_ERROR</code>.</small>
  581. * [Rel: Skylink.DATA_CHANNEL_MESSAGE_ERROR]
  582. * @param {JSON} bufferAmount The Datachannel buffered amount information.
  583. * @param {Number} bufferAmount.bufferedAmountLow The size of currently queued data to send on the Datachannel connection.
  584. * @param {Number} bufferAmount.bufferedAmountLowThreshold The current buffered amount low threshold configured.
  585. * @for Skylink
  586. * @since 0.1.0
  587. */
  588. dataChannelState: [],
  589.  
  590. /**
  591. * Event triggered when a data transfer state has changed.
  592. * @event dataTransferState
  593. * @param {String} state The current data transfer state.
  594. * [Rel: Skylink.DATA_TRANSFER_STATE]
  595. * @param {String} transferId The data transfer ID.
  596. * <small>Note that this is defined as <code>null</code> when <code>state</code> payload is <code>START_ERROR</code>.</small>
  597. * @param {String} peerId The Peer ID.
  598. * <small>Note that this could be defined as <code>null</code> when <code>state</code> payload is
  599. * <code>START_ERROR</code> and there is no Peers to start data transfer with.</small>
  600. * @param {JSON} transferInfo The data transfer information.
  601. * @param {Blob|String} [transferInfo.data] The data object.
  602. * <small>Defined only when <code>state</code> payload is <code>UPLOAD_STARTED</code> or
  603. * <code>DOWNLOAD_COMPLETED</code>.</small>
  604. * @param {String} transferInfo.name The data transfer name.
  605. * @param {Number} transferInfo.size The data transfer data object size.
  606. * @param {String} transferInfo.dataType The data transfer session type.
  607. * [Rel: Skylink.DATA_TRANSFER_SESSION_TYPE]
  608. * @param {String} transferInfo.chunkType The data transfer type of data chunk being used to send to Peer for transfers.
  609. * <small>For <a href="#method_sendBlobData"><code>sendBlobData()</code> method</a> data transfers, the
  610. * initial data chunks value may change depending on the currently received data chunk type or the
  611. * agent supported sending type of data chunks.</small>
  612. * <small>For <a href="#method_sendURLData"><code>sendURLData()</code> method</a> data transfers, it is
  613. * <code>STRING</code> always.</small>
  614. * [Rel: Skylink.DATA_TRANSFER_DATA_TYPE]
  615. * @param {String} [transferInfo.mimeType] The data transfer data object MIME type.
  616. * <small>Defined only when <a href="#method_sendBlobData"><code>sendBlobData()</code> method</a>
  617. * data object sent MIME type information is defined.</small>
  618. * @param {Number} transferInfo.chunkSize The data transfer data chunk size.
  619. * @param {Number} transferInfo.percentage The data transfer percentage of completion progress.
  620. * @param {Number} transferInfo.timeout The flag if data transfer is targeted or not, basing
  621. * off the <code>targetPeerId</code> parameter being defined in
  622. * <a href="#method_sendURLData"><code>sendURLData()</code> method</a> or
  623. * <a href="#method_sendBlobData"><code>sendBlobData()</code> method</a>.
  624. * @param {Boolean} transferInfo.isPrivate The flag if message is targeted or not, basing
  625. * off the <code>targetPeerId</code> parameter being defined in
  626. * <a href="#method_sendBlobData"><code>sendBlobData()</code> method</a> or
  627. * <a href="#method_sendURLData"><code>sendURLData()</code> method</a>.
  628. * @param {String} transferInfo.direction The data transfer direction.
  629. * [Rel: Skylink.DATA_TRANSFER_TYPE]
  630. * @param {JSON} [error] The error result.
  631. * <small>Defined only when <code>state</code> payload is <code>ERROR</code>, <code>CANCEL</code>,
  632. * <code>REJECTED</code>, <code>START_ERROR</code> or <code>USER_REJECTED</code>.</small>
  633. * @param {Error|String} error.message The error object.
  634. * @param {String} error.transferType The data transfer direction from where the error occurred.
  635. * [Rel: Skylink.DATA_TRANSFER_TYPE]
  636. * @for Skylink
  637. * @since 0.4.1
  638. */
  639. dataTransferState: [],
  640.  
  641. /**
  642. * Event triggered when a data streaming state has changed.
  643. * @event dataStreamState
  644. * @param {String} state The current data streaming state.
  645. * [Rel: Skylink.DATA_STREAM_STATE]
  646. * @param {String} streamId The data streaming session ID.
  647. * <small>Note that this is defined as <code>null</code> when <code>state</code> payload is <code>START_ERROR</code>.</small>
  648. * @param {String} peerId The Peer ID.
  649. * <small>Note that this could be defined as <code>null</code> when <code>state</code> payload is
  650. * <code>START_ERROR</code> and there is no Peers to start data streaming with.</small>
  651. * @param {JSON} streamInfo The data streaming information.
  652. * @param {Blob|String} [streamInfo.chunk] The data chunk received.
  653. * <small>Defined only when <code>state</code> payload is <code>RECEIVED</code> or <code>SENT</code>.</small>
  654. * @param {Number} streamInfo.chunkSize The data streaming data chunk size received.
  655. * @param {String} streamInfo.chunkType The data streaming data chunk type received.
  656. * <small>The initial data chunks value may change depending on the currently received data chunk type or the
  657. * agent supported sending type of data chunks.</small>
  658. * [Rel: Skylink.DATA_TRANSFER_DATA_TYPE]
  659. * @param {String} streamInfo.isStringStream The flag if data streaming data chunks are strings.
  660. * @param {Boolean} streamInfo.isPrivate The flag if data streaming is targeted or not, basing
  661. * off the <code>targetPeerId</code> parameter being defined in
  662. * <a href="#method_startStreamingData"><code>startStreamingData()</code> method</a>.
  663. * @param {String} streamInfo.senderPeerId The sender Peer ID.
  664. * @param {Error} [error] The error object.
  665. * <small>Defined only when <code>state</code> payload is <code>ERROR</code> or <code>START_ERROR</code>,.</small>
  666. * @beta
  667. * @for Skylink
  668. * @since 0.6.18
  669. */
  670. dataStreamState: [],
  671.  
  672. /**
  673. * Event triggered when Signaling server reaction state has changed.
  674. * @event systemAction
  675. * @param {String} action The current Signaling server reaction state.
  676. * [Rel: Skylink.SYSTEM_ACTION]
  677. * @param {String} message The message.
  678. * @param {String} reason The Signaling server reaction state reason of action code.
  679. * [Rel: Skylink.SYSTEM_ACTION_REASON]
  680. * @for Skylink
  681. * @since 0.5.1
  682. */
  683. systemAction: [],
  684.  
  685. /**
  686. * Event triggered when a server Peer joins the room.
  687. * @event serverPeerJoined
  688. * @param {String} peerId The Peer ID.
  689. * @param {String} serverPeerType The server Peer type
  690. * [Rel: Skylink.SERVER_PEER_TYPE]
  691. * @for Skylink
  692. * @since 0.6.1
  693. */
  694. serverPeerJoined: [],
  695.  
  696. /**
  697. * Event triggered when a server Peer leaves the room.
  698. * @event serverPeerLeft
  699. * @param {String} peerId The Peer ID.
  700. * @param {String} serverPeerType The server Peer type
  701. * [Rel: Skylink.SERVER_PEER_TYPE]
  702. * @for Skylink
  703. * @since 0.6.1
  704. */
  705. serverPeerLeft: [],
  706.  
  707. /**
  708. * Event triggered when a server Peer connection has been refreshed.
  709. * @event serverPeerRestart
  710. * @param {String} peerId The Peer ID.
  711. * @param {String} serverPeerType The server Peer type
  712. * [Rel: Skylink.SERVER_PEER_TYPE]
  713. * @for Skylink
  714. * @since 0.6.1
  715. */
  716. serverPeerRestart: [],
  717.  
  718. /**
  719. * Event triggered when a Peer Stream streaming has stopped.
  720. * <small>Note that it may not be the currently sent Stream to User, and it also triggers
  721. * when User leaves the Room for any currently sent Stream to User from Peer.</small>
  722. * @event streamEnded
  723. * @param {String} peerId The Peer ID.
  724. * @param {JSON} peerInfo The Peer session information.
  725. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  726. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  727. * @param {Boolean} isSelf The flag if Peer is User.
  728. * @param {Boolean} isScreensharing The flag if Peer Stream is a screensharing Stream.
  729. * @param {String} streamId The Stream ID.
  730. * @for Skylink
  731. * @since 0.5.10
  732. */
  733. streamEnded: [],
  734.  
  735. /**
  736. * Event triggered when Peer Stream audio or video tracks has been muted / unmuted.
  737. * @event streamMuted
  738. * @param {String} peerId The Peer ID.
  739. * @param {JSON} peerInfo The Peer session information.
  740. * <small>Object signature matches the <code>peerInfo</code> parameter payload received in the
  741. * <a href="#event_peerJoined"><code>peerJoined</code> event</a>.</small>
  742. * @param {Boolean} isSelf The flag if Peer is User.
  743. * @param {Boolean} isScreensharing The flag if Peer Stream is a screensharing Stream.
  744. * @for Skylink
  745. * @since 0.6.1
  746. */
  747. streamMuted: [],
  748.  
  749. /**
  750. * Event triggered when <a href="#method_getPeers"><code>getPeers()</code> method</a> retrieval state changes.
  751. * @event getPeersStateChange
  752. * @param {String} state The current <code>getPeers()</code> retrieval state.
  753. * [Rel: Skylink.GET_PEERS_STATE]
  754. * @param {String} privilegedPeerId The User's privileged Peer ID.
  755. * @param {JSON} peerList The list of Peer IDs Rooms within the same App space.
  756. * @param {Array} peerList.#room The list of Peer IDs associated with the Room defined in <code>#room</code> property.
  757. * @for Skylink
  758. * @since 0.6.1
  759. */
  760. getPeersStateChange: [],
  761.  
  762. /**
  763. * Event triggered when <a href="#method_introducePeer"><code>introducePeer()</code> method</a>
  764. * introduction request state changes.
  765. * @event introduceStateChange
  766. * @param {String} state The current <code>introducePeer()</code> introduction request state.
  767. * [Rel: Skylink.INTRODUCE_STATE]
  768. * @param {String} privilegedPeerId The User's privileged Peer ID.
  769. * @param {String} sendingPeerId The Peer ID to be connected with <code>receivingPeerId</code>.
  770. * @param {String} receivingPeerId The Peer ID to be connected with <code>sendingPeerId</code>.
  771. * @param {String} [reason] The error object.
  772. * <small>Defined only when <code>state</code> payload is <code>ERROR</code>.</small>
  773. * @for Skylink
  774. * @since 0.6.1
  775. */
  776. introduceStateChange: [],
  777.  
  778. /**
  779. * Event triggered when recording session state has changed.
  780. * @event recordingState
  781. * @param {Number} state The current recording session state.
  782. * [Rel: Skylink.RECORDING_STATE]
  783. * @param {String} recordingId The recording session ID.
  784. * @param {JSON} link The recording session mixin videos link in
  785. * <a href="https://en.wikipedia.org/wiki/MPEG-4_Part_14">MP4</a> format.
  786. * <small>Defined only when <code>state</code> payload is <code>LINK</code>.</small>
  787. * @param {String} link.#peerId The recording session recorded Peer only video associated
  788. * with the Peer ID defined in <code>#peerId</code> property.
  789. * <small>If <code>#peerId</code> value is <code>"mixin"</code>, it means that is the mixin
  790. * video of all Peers in the Room.</small>
  791. * @param {Error|String} error The error object.
  792. * <small>Defined only when <code>state</code> payload is <code>ERROR</code>.</small>
  793. * @beta
  794. * @for Skylink
  795. * @since 0.6.16
  796. */
  797. recordingState: [],
  798.  
  799. /**
  800. * Event triggered when RTMP session state has changed.
  801. * @event rtmpState
  802. * @param {Number} state The current RTMP session state.
  803. * [Rel: Skylink.RTMP_STATE]
  804. * @param {String} rtmpId The rtmp session ID.
  805. * @param {Error|String} error The error object.
  806. * <small>Defined only when <code>state</code> payload is <code>ERROR</code>.</small>
  807. * @beta
  808. * @for Skylink
  809. * @since 0.6.36
  810. */
  811.  
  812. RTMPState: [],
  813.  
  814. /**
  815. * Event triggered when <a href="#method_getConnectionStatus"><code>getConnectionStatus()</code> method</a>
  816. * retrieval state changes.
  817. * @event getConnectionStatusStateChange
  818. * @param {Number} state The current <code>getConnectionStatus()</code> retrieval state.
  819. * [Rel: Skylink.GET_CONNECTION_STATUS_STATE]
  820. * @param {String} peerId The Peer ID.
  821. * @param {JSON} [stats] The Peer connection current stats.
  822. * <small>Defined only when <code>state</code> payload is <code>RETRIEVE_SUCCESS</code>.</small>
  823. * @param {JSON} stats.raw The Peer connection raw stats before parsing.
  824. * @param {JSON} stats.audio The Peer connection audio streaming stats.
  825. * @param {JSON} stats.audio.sending The Peer connection sending audio streaming stats.
  826. * @param {Number} stats.audio.sending.bytes The Peer connection current sending audio streaming bytes.
  827. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  828. * @param {Number} stats.audio.sending.totalBytes The Peer connection total sending audio streaming bytes.
  829. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  830. * @param {Number} stats.audio.sending.packets The Peer connection current sending audio streaming packets.
  831. * @param {Number} stats.audio.sending.totalPackets The Peer connection total sending audio streaming packets.
  832. * @param {Number} stats.audio.sending.packetsLost <blockquote class="info">
  833. * This property has been deprecated and would be removed in future releases
  834. * as it should not be in <code>sending</code> property.
  835. * </blockquote> The Peer connection current sending audio streaming packets lost.
  836. * @param {Number} stats.audio.sending.totalPacketsLost <blockquote class="info">
  837. * This property has been deprecated and would be removed in future releases
  838. * as it should not be in <code>sending</code> property.
  839. * </blockquote> The Peer connection total sending audio streaming packets lost.
  840. * @param {Number} stats.audio.sending.ssrc The Peer connection sending audio streaming RTP packets SSRC.
  841. * @param {Number} stats.audio.sending.rtt The Peer connection sending audio streaming RTT (Round-trip delay time).
  842. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  843. * @param {Number} stats.audio.sending.jitter <blockquote class="info">
  844. * This property has been deprecated and would be removed in future releases
  845. * as it should not be in <code>sending</code> property.
  846. * </blockquote> The Peer connection sending audio streaming RTP packets jitter in seconds.
  847. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  848. * @param {Number} [stats.audio.sending.jitterBufferMs] <blockquote class="info">
  849. * This property has been deprecated and would be removed in future releases
  850. * as it should not be in <code>sending</code> property.
  851. * </blockquote> The Peer connection sending audio streaming
  852. * RTP packets jitter buffer in miliseconds.
  853. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  854. * @param {JSON} [stats.audio.sending.codec] The Peer connection sending audio streaming selected codec information.
  855. * <small>Defined as <code>null</code> if local session description is not available before parsing.</small>
  856. * @param {String} stats.audio.sending.codec.name The Peer connection sending audio streaming selected codec name.
  857. * @param {Number} stats.audio.sending.codec.payloadType The Peer connection sending audio streaming selected codec payload type.
  858. * @param {String} [stats.audio.sending.codec.implementation] The Peer connection sending audio streaming selected codec implementation.
  859. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  860. * @param {Number} [stats.audio.sending.codec.channels] The Peer connection sending audio streaming selected codec channels (2 for stereo).
  861. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing,
  862. * and this is usually present in <code>stats.audio</code> property.</small>
  863. * @param {Number} [stats.audio.sending.codec.clockRate] The Peer connection sending audio streaming selected codec media sampling rate.
  864. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  865. * @param {String} [stats.audio.sending.codec.params] The Peer connection sending audio streaming selected codec parameters.
  866. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  867. * @param {Number} [stats.audio.sending.inputLevel] The Peer connection sending audio streaming input level.
  868. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  869. * @param {Number} [stats.audio.sending.echoReturnLoss] The Peer connection sending audio streaming echo return loss in db (decibels).
  870. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  871. * @param {Number} [stats.audio.sending.echoReturnLossEnhancement] The Peer connection sending audio streaming
  872. * echo return loss enhancement db (decibels).
  873. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  874. * @param {JSON} stats.audio.receiving The Peer connection receiving audio streaming stats.
  875. * @param {Number} stats.audio.receiving.bytes The Peer connection current sending audio streaming bytes.
  876. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  877. * @param {Number} stats.audio.receiving.totalBytes The Peer connection total sending audio streaming bytes.
  878. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  879. * @param {Number} stats.audio.receiving.packets The Peer connection current receiving audio streaming packets.
  880. * @param {Number} stats.audio.receiving.totalPackets The Peer connection total receiving audio streaming packets.
  881. * @param {Number} stats.audio.receiving.packetsLost The Peer connection current receiving audio streaming packets lost.
  882. * @param {Number} stats.audio.receiving.fractionLost The Peer connection current receiving audio streaming fraction packets lost.
  883. * @param {Number} stats.audio.receiving.packetsDiscarded The Peer connection current receiving audio streaming packets discarded.
  884. * @param {Number} stats.audio.receiving.totalPacketsLost The Peer connection total receiving audio streaming packets lost.
  885. * @param {Number} stats.audio.receiving.totalPacketsDiscarded The Peer connection total receiving audio streaming packets discarded.
  886. * @param {Number} stats.audio.receiving.ssrc The Peer connection receiving audio streaming RTP packets SSRC.
  887. * @param {Number} stats.audio.receiving.jitter The Peer connection receiving audio streaming RTP packets jitter in seconds.
  888. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  889. * @param {Number} [stats.audio.receiving.jitterBufferMs] The Peer connection receiving audio streaming
  890. * RTP packets jitter buffer in miliseconds.
  891. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  892. * @param {JSON} [stats.audio.receiving.codec] The Peer connection receiving audio streaming selected codec information.
  893. * <small>Defined as <code>null</code> if remote session description is not available before parsing.</small>
  894. * <small>Note that if the value is polyfilled, the value may not be accurate since the remote Peer can override the selected codec.
  895. * The value is derived from the remote session description.</small>
  896. * @param {String} stats.audio.receiving.codec.name The Peer connection receiving audio streaming selected codec name.
  897. * @param {Number} stats.audio.receiving.codec.payloadType The Peer connection receiving audio streaming selected codec payload type.
  898. * @param {String} [stats.audio.receiving.codec.implementation] The Peer connection receiving audio streaming selected codec implementation.
  899. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  900. * @param {Number} [stats.audio.receiving.codec.channels] The Peer connection receiving audio streaming selected codec channels (2 for stereo).
  901. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing,
  902. * and this is usually present in <code>stats.audio</code> property.</small>
  903. * @param {Number} [stats.audio.receiving.codec.clockRate] The Peer connection receiving audio streaming selected codec media sampling rate.
  904. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  905. * @param {String} [stats.audio.receiving.codec.params] The Peer connection receiving audio streaming selected codec parameters.
  906. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  907. * @param {Number} [stats.audio.receiving.outputLevel] The Peer connection receiving audio streaming output level.
  908. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  909. * @param {JSON} stats.video The Peer connection video streaming stats.
  910. * @param {JSON} stats.video.sending The Peer connection sending video streaming stats.
  911. * @param {Number} stats.video.sending.bytes The Peer connection current sending video streaming bytes.
  912. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  913. * @param {Number} stats.video.sending.totalBytes The Peer connection total sending video streaming bytes.
  914. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  915. * @param {Number} stats.video.sending.packets The Peer connection current sending video streaming packets.
  916. * @param {Number} stats.video.sending.totalPackets The Peer connection total sending video streaming packets.
  917. * @param {Number} stats.video.sending.packetsLost <blockquote class="info">
  918. * This property has been deprecated and would be removed in future releases
  919. * as it should not be in <code>sending</code> property.
  920. * </blockquote> The Peer connection current sending video streaming packets lost.
  921. * @param {Number} stats.video.sending.totalPacketsLost <blockquote class="info">
  922. * This property has been deprecated and would be removed in future releases
  923. * as it should not be in <code>sending</code> property.
  924. * </blockquote> The Peer connection total sending video streaming packets lost.
  925. * @param {Number} stats.video.sending.ssrc The Peer connection sending video streaming RTP packets SSRC.
  926. * @param {Number} stats.video.sending.rtt The Peer connection sending video streaming RTT (Round-trip delay time).
  927. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  928. * @param {Number} stats.video.sending.jitter <blockquote class="info">
  929. * This property has been deprecated and would be removed in future releases
  930. * as it should not be in <code>sending</code> property.
  931. * </blockquote> The Peer connection sending video streaming RTP packets jitter in seconds.
  932. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  933. * @param {Number} [stats.video.sending.jitterBufferMs] <blockquote class="info">
  934. * This property has been deprecated and would be removed in future releases
  935. * as it should not be in <code>sending</code> property.
  936. * </blockquote> The Peer connection sending video streaming RTP packets jitter buffer in miliseconds.
  937. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  938. * @param {Number} [stats.video.sending.qpSum] The Peer connection sending video streaming sum of the QP values of frames passed.
  939. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  940. * @param {JSON} [stats.video.sending.codec] The Peer connection sending video streaming selected codec information.
  941. * <small>Defined as <code>null</code> if local session description is not available before parsing.</small>
  942. * @param {String} stats.video.sending.codec.name The Peer connection sending video streaming selected codec name.
  943. * @param {Number} stats.video.sending.codec.payloadType The Peer connection sending video streaming selected codec payload type.
  944. * @param {String} [stats.video.sending.codec.implementation] The Peer connection sending video streaming selected codec implementation.
  945. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  946. * @param {Number} [stats.video.sending.codec.channels] The Peer connection sending video streaming selected codec channels (2 for stereo).
  947. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing,
  948. * and this is usually present in <code>stats.audio</code> property.</small>
  949. * @param {Number} [stats.video.sending.codec.clockRate] The Peer connection sending video streaming selected codec media sampling rate.
  950. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  951. * @param {String} [stats.video.sending.codec.params] The Peer connection sending video streaming selected codec parameters.
  952. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  953. * @param {Number} [stats.video.sending.frames] The Peer connection sending video streaming frames.
  954. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  955. * @param {Number} [stats.video.sending.frameRateInput] The Peer connection sending video streaming fps input.
  956. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  957. * @param {Number} [stats.video.sending.frameRateInput] The Peer connection sending video streaming fps input.
  958. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  959. * @param {Number} [stats.video.sending.framesDropped] The Peer connection sending video streaming frames dropped.
  960. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  961. * @param {Number} [stats.video.sending.frameRateMean] The Peer connection sending video streaming fps mean.
  962. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  963. * @param {Number} [stats.video.sending.frameRateStdDev] The Peer connection sending video streaming fps standard deviation.
  964. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  965. * @param {Number} [stats.video.sending.framesPerSecond] The Peer connection sending video streaming fps.
  966. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  967. * @param {Number} [stats.video.sending.framesDecoded] The Peer connection sending video streaming frames decoded.
  968. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  969. * @param {Number} [stats.video.sending.framesCorrupted] The Peer connection sending video streaming frames corrupted.
  970. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  971. * @param {Number} [stats.video.sending.totalFrames] The Peer connection total sending video streaming frames.
  972. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  973. * @param {Number} [stats.video.sending.nacks] The Peer connection current sending video streaming nacks.
  974. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  975. * @param {Number} [stats.video.sending.totalNacks] The Peer connection total sending video streaming nacks.
  976. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  977. * @param {Number} [stats.video.sending.plis] The Peer connection current sending video streaming plis.
  978. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  979. * @param {Number} [stats.video.sending.totalPlis] The Peer connection total sending video streaming plis.
  980. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  981. * @param {Number} [stats.video.sending.firs] The Peer connection current sending video streaming firs.
  982. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  983. * @param {Number} [stats.video.sending.totalFirs] The Peer connection total sending video streaming firs.
  984. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  985. * @param {Number} [stats.video.sending.slis] The Peer connection current sending video streaming slis.
  986. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  987. * @param {Number} [stats.video.sending.totalSlis] The Peer connection total sending video streaming slis.
  988. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  989. * @param {JSON} stats.video.receiving The Peer connection receiving video streaming stats.
  990. * @param {Number} stats.video.receiving.bytes The Peer connection current receiving video streaming bytes.
  991. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  992. * @param {Number} stats.video.receiving.totalBytes The Peer connection total receiving video streaming bytes.
  993. * <small>Note that value is in bytes so you have to convert that to bits for displaying for an example kbps.</small>
  994. * @param {Number} stats.video.receiving.packets The Peer connection current receiving video streaming packets.
  995. * @param {Number} stats.video.receiving.totalPackets The Peer connection total receiving video streaming packets.
  996. * @param {Number} stats.video.receiving.packetsLost The Peer connection current receiving video streaming packets lost.
  997. * @param {Number} stats.video.receiving.fractionLost The Peer connection current receiving video streaming fraction packets lost.
  998. * @param {Number} stats.video.receiving.packetsDiscarded The Peer connection current receiving video streaming packets discarded.
  999. * @param {Number} stats.video.receiving.totalPacketsLost The Peer connection total receiving video streaming packets lost.
  1000. * @param {Number} stats.video.receiving.totalPacketsDiscarded The Peer connection total receiving video streaming packets discarded.
  1001. * @param {Number} stats.video.receiving.ssrc The Peer connection receiving video streaming RTP packets SSRC.
  1002. * @param {Number} [stats.video.receiving.e2eDelay] The Peer connection receiving video streaming e2e delay.
  1003. * <small>Defined as <code>null</code> if it's not present in original raw stats before parsing, and that
  1004. * it finds any existing audio, video or object (plugin) DOM elements that has set with the
  1005. * Peer remote stream object to parse current time. Note that <code>document.getElementsByTagName</code> function
  1006. * and DOM <code>.currentTime</code> has to be supported inorder for data to be parsed correctly.</small>
  1007. * @param {Number} stats.video.receiving.jitter The Peer connection receiving video streaming RTP packets jitter in seconds.
  1008. * <small>Defined as <code>0</code> if it's not present in original raw stats before parsing.</small>
  1009. * @param {Number} [stats.video.receiving.jitterBufferMs] The Peer connection receiving video streaming
  1010. * RTP packets jitter buffer in miliseconds.
  1011. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1012. * @param {JSON} [stats.video.receiving.codec] The Peer connection receiving video streaming selected codec information.
  1013. * <small>Defined as <code>null</code> if remote session description is not available before parsing.</small>
  1014. * <small>Note that if the value is polyfilled, the value may not be accurate since the remote Peer can override the selected codec.
  1015. * The value is derived from the remote session description.</small>
  1016. * @param {String} stats.video.receiving.codec.name The Peer connection receiving video streaming selected codec name.
  1017. * @param {Number} stats.video.receiving.codec.payloadType The Peer connection receiving video streaming selected codec payload type.
  1018. * @param {String} [stats.video.receiving.codec.implementation] The Peer connection receiving video streaming selected codec implementation.
  1019. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1020. * @param {Number} [stats.video.receiving.codec.channels] The Peer connection receiving video streaming selected codec channels (2 for stereo).
  1021. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing,
  1022. * and this is usually present in <code>stats.audio</code> property.</small>
  1023. * @param {Number} [stats.video.receiving.codec.clockRate] The Peer connection receiving video streaming selected codec media sampling rate.
  1024. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1025. * @param {String} [stats.video.receiving.codec.params] The Peer connection receiving video streaming selected codec parameters.
  1026. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1027. * @param {Number} [stats.video.receiving.frames] The Peer connection receiving video streaming frames.
  1028. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1029. * @param {Number} [stats.video.receiving.framesOutput] The Peer connection receiving video streaming fps output.
  1030. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1031. * @param {Number} [stats.video.receiving.framesDecoded] The Peer connection receiving video streaming frames decoded.
  1032. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1033. * @param {Number} [stats.video.receiving.frameRateMean] The Peer connection receiving video streaming fps mean.
  1034. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1035. * @param {Number} [stats.video.receiving.frameRateStdDev] The Peer connection receiving video streaming fps standard deviation.
  1036. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1037. * @param {Number} [stats.video.receiving.framesPerSecond] The Peer connection receiving video streaming fps.
  1038. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1039. * @param {Number} [stats.video.receiving.framesDecoded] The Peer connection receiving video streaming frames decoded.
  1040. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1041. * @param {Number} [stats.video.receiving.framesCorrupted] The Peer connection receiving video streaming frames corrupted.
  1042. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1043. * @param {Number} [stats.video.receiving.totalFrames] The Peer connection total receiving video streaming frames.
  1044. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1045. * @param {Number} [stats.video.receiving.nacks] The Peer connection current receiving video streaming nacks.
  1046. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1047. * @param {Number} [stats.video.receiving.totalNacks] The Peer connection total receiving video streaming nacks.
  1048. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1049. * @param {Number} [stats.video.receiving.plis] The Peer connection current receiving video streaming plis.
  1050. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1051. * @param {Number} [stats.video.receiving.totalPlis] The Peer connection total receiving video streaming plis.
  1052. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1053. * @param {Number} [stats.video.receiving.firs] The Peer connection current receiving video streaming firs.
  1054. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1055. * @param {Number} [stats.video.receiving.totalFirs] The Peer connection total receiving video streaming firs.
  1056. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1057. * @param {Number} [stats.video.receiving.slis] The Peer connection current receiving video streaming slis.
  1058. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1059. * @param {Number} [stats.video.receiving.totalPlis] The Peer connection total receiving video streaming slis.
  1060. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1061. * @param {JSON} stats.selectedCandidate The Peer connection selected ICE candidate pair stats.
  1062. * @param {JSON} stats.selectedCandidate.local The Peer connection selected local ICE candidate.
  1063. * @param {String} stats.selectedCandidate.local.ipAddress The Peer connection selected
  1064. * local ICE candidate IP address.
  1065. * @param {Number} stats.selectedCandidate.local.portNumber The Peer connection selected
  1066. * local ICE candidate port number.
  1067. * @param {String} stats.selectedCandidate.local.transport The Peer connection selected
  1068. * local ICE candidate IP transport type.
  1069. * @param {String} stats.selectedCandidate.local.candidateType The Peer connection selected
  1070. * local ICE candidate type.
  1071. * @param {String} [stats.selectedCandidate.local.turnMediaTransport] The Peer connection possible
  1072. * transport used when relaying local media to TURN server.
  1073. * <small>Types are <code>"UDP"</code> (UDP connections), <code>"TCP"</code> (TCP connections) and
  1074. * <code>"TCP/TLS"</code> (TCP over TLS connections).</small>
  1075. * @param {JSON} stats.selectedCandidate.remote The Peer connection selected remote ICE candidate.
  1076. * @param {String} stats.selectedCandidate.remote.ipAddress The Peer connection selected
  1077. * remote ICE candidate IP address.
  1078. * @param {Number} stats.selectedCandidate.remote.portNumber The Peer connection selected
  1079. * remote ICE candidate port number.
  1080. * @param {String} stats.selectedCandidate.remote.transport The Peer connection selected
  1081. * remote ICE candidate IP transport type.
  1082. * @param {String} stats.selectedCandidate.remote.candidateType The Peer connection selected
  1083. * remote ICE candidate type.
  1084. * @param {Boolean} [stats.selectedCandidate.writable] The flag if Peer has gotten ACK to an ICE request.
  1085. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1086. * @param {Boolean} [stats.selectedCandidate.readable] The flag if Peer has gotten a valid incoming ICE request.
  1087. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1088. * @param {String} [stats.selectedCandidate.rtt] The current STUN connectivity checks RTT (Round-trip delay time).
  1089. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1090. * @param {String} [stats.selectedCandidate.totalRtt] The total STUN connectivity checks RTT (Round-trip delay time).
  1091. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1092. * @param {JSON} stats.selectedCandidate.requests The ICE connectivity check requests.
  1093. * @param {String} [stats.selectedCandidate.requests.received] The current ICE connectivity check requests received.
  1094. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1095. * @param {String} [stats.selectedCandidate.requests.sent] The current ICE connectivity check requests sent.
  1096. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1097. * @param {String} [stats.selectedCandidate.requests.totalReceived] The total ICE connectivity check requests received.
  1098. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1099. * @param {String} [stats.selectedCandidate.requests.totalSent] The total ICE connectivity check requests sent.
  1100. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1101. * @param {JSON} stats.selectedCandidate.responses The ICE connectivity check responses.
  1102. * @param {String} [stats.selectedCandidate.responses.received] The current ICE connectivity check responses received.
  1103. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1104. * @param {String} [stats.selectedCandidate.responses.sent] The current ICE connectivity check responses sent.
  1105. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1106. * @param {String} [stats.selectedCandidate.responses.totalReceived] The total ICE connectivity check responses received.
  1107. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1108. * @param {String} [stats.selectedCandidate.responses.totalSent] The total ICE connectivity check responses sent.
  1109. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1110. * @param {JSON} stats.selectedCandidate.consentRequests The current ICE consent requests.
  1111. * @param {String} [stats.selectedCandidate.consentRequests.received] The current ICE consent requests received.
  1112. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1113. * @param {String} [stats.selectedCandidate.consentRequests.sent] The current ICE consent requests sent.
  1114. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1115. * @param {String} [stats.selectedCandidate.consentRequests.totalReceived] The total ICE consent requests received.
  1116. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1117. * @param {String} [stats.selectedCandidate.consentRequests.totalSent] The total ICE consent requests sent.
  1118. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1119. * @param {JSON} stats.selectedCandidate.consentResponses The current ICE consent responses.
  1120. * @param {String} [stats.selectedCandidate.consentResponses.received] The current ICE consent responses received.
  1121. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1122. * @param {String} [stats.selectedCandidate.consentResponses.sent] The current ICE consent responses sent.
  1123. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1124. * @param {String} [stats.selectedCandidate.consentResponses.totalReceived] The total ICE consent responses received.
  1125. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1126. * @param {String} [stats.selectedCandidate.consentResponses.totalSent] The total ICE consent responses sent.
  1127. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1128. * @param {JSON} stats.certificate The Peer connection DTLS/SRTP exchanged certificates information.
  1129. * @param {JSON} stats.certificate.local The Peer connection local certificate information.
  1130. * @param {String} [stats.certificate.local.fingerprint] The Peer connection local certificate fingerprint.
  1131. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1132. * @param {String} [stats.certificate.local.fingerprintAlgorithm] The Peer connection local
  1133. * certificate fingerprint algorithm.
  1134. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1135. * @param {String} [stats.certificate.local.derBase64] The Peer connection local
  1136. * base64 certificate in binary DER format encoded in base64.
  1137. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1138. * @param {JSON} stats.certificate.remote The Peer connection remote certificate information.
  1139. * @param {String} [stats.certificate.remote.fingerprint] The Peer connection remote certificate fingerprint.
  1140. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1141. * @param {String} [stats.certificate.remote.fingerprintAlgorithm] The Peer connection remote
  1142. * certificate fingerprint algorithm.
  1143. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1144. * @param {String} [stats.certificate.remote.derBase64] The Peer connection remote
  1145. * base64 certificate in binary DER format encoded in base64.
  1146. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1147. * @param {String} [stats.certificate.srtpCipher] The certificates SRTP cipher.
  1148. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1149. * @param {String} [stats.certificate.dtlsCipher] The certificates DTLS cipher.
  1150. * <small>Defined as <code>null</code> if it's not available in original raw stats before parsing.</small>
  1151. * @param {JSON} stats.connection The Peer connection object stats.
  1152. * @param {String} stats.connection.iceConnectionState The Peer connection ICE connection state.
  1153. * @param {String} stats.connection.iceGatheringState The Peer connection ICE gathering state.
  1154. * @param {String} stats.connection.signalingState The Peer connection signaling state.
  1155. * @param {JSON} stats.connection.localDescription The Peer connection local session description.
  1156. * @param {String} stats.connection.localDescription.type The Peer connection local session description type.
  1157. * <small>Defined as <code>null</code> when local session description is not available.</small>
  1158. * @param {String} stats.connection.localDescription.sdp The Peer connection local session description SDP.
  1159. * <small>Defined as <code>null</code> when local session description is not available.</small>
  1160. * @param {JSON} stats.connection.remoteDescription The Peer connection remote session description.
  1161. * @param {String} stats.connection.remoteDescription.type The Peer connection remote session description type.
  1162. * <small>Defined as <code>null</code> when remote session description is not available.</small>
  1163. * @param {String} stats.connection.remoteDescription.sdp The Peer connection remote session description sdp.
  1164. * <small>Defined as <code>null</code> when remote session description is not available.</small>
  1165. * @param {JSON} stats.connection.candidates The Peer connection list of ICE candidates sent or received.
  1166. * @param {JSON} stats.connection.candidates.sending The Peer connection list of local ICE candidates sent.
  1167. * @param {Array} stats.connection.candidates.sending.host The Peer connection list of local
  1168. * <code>"host"</code> (local network) ICE candidates sent.
  1169. * @param {JSON} stats.connection.candidates.sending.host.#index The Peer connection local
  1170. * <code>"host"</code> (local network) ICE candidate.
  1171. * @param {String} stats.connection.candidates.sending.host.#index.candidate The Peer connection local
  1172. * <code>"host"</code> (local network) ICE candidate connection description.
  1173. * @param {String} stats.connection.candidates.sending.host.#index.sdpMid The Peer connection local
  1174. * <code>"host"</code> (local network) ICE candidate identifier based on the local session description.
  1175. * @param {Number} stats.connection.candidates.sending.host.#index.sdpMLineIndex The Peer connection local
  1176. * <code>"host"</code> (local network) ICE candidate media description index (starting from <code>0</code>)
  1177. * based on the local session description.
  1178. * @param {Array} stats.connection.candidates.sending.srflx The Peer connection list of local
  1179. * <code>"srflx"</code> (STUN) ICE candidates sent.
  1180. * @param {JSON} stats.connection.candidates.sending.srflx.#index The Peer connection local
  1181. * <code>"srflx"</code> (STUN) ICE candidate.
  1182. * @param {String} stats.connection.candidates.sending.srflx.#index.candidate The Peer connection local
  1183. * <code>"srflx"</code> (STUN) ICE candidate connection description.
  1184. * @param {String} stats.connection.candidates.sending.srflx.#index.sdpMid The Peer connection local
  1185. * <code>"srflx"</code> (STUN) ICE candidate identifier based on the local session description.
  1186. * @param {Number} stats.connection.candidates.sending.srflx.#index.sdpMLineIndex The Peer connection local
  1187. * <code>"srflx"</code> (STUN) ICE candidate media description index (starting from <code>0</code>)
  1188. * based on the local session description.
  1189. * @param {Array} stats.connection.candidates.sending.relay The Peer connection list of local
  1190. * <code>"relay"</code> (TURN) candidates sent.
  1191. * @param {JSON} stats.connection.candidates.sending.relay.#index The Peer connection local
  1192. * <code>"relay"</code> (TURN) ICE candidate.
  1193. * @param {String} stats.connection.candidates.sending.relay.#index.candidate The Peer connection local
  1194. * <code>"relay"</code> (TURN) ICE candidate connection description.
  1195. * @param {String} stats.connection.candidates.sending.relay.#index.sdpMid The Peer connection local
  1196. * <code>"relay"</code> (TURN) ICE candidate identifier based on the local session description.
  1197. * @param {Number} stats.connection.candidates.sending.relay.#index.sdpMLineIndex The Peer connection local
  1198. * <code>"relay"</code> (TURN) ICE candidate media description index (starting from <code>0</code>)
  1199. * based on the local session description.
  1200. * @param {JSON} stats.connection.candidates.receiving The Peer connection list of remote ICE candidates received.
  1201. * @param {Array} stats.connection.candidates.receiving.host The Peer connection list of remote
  1202. * <code>"host"</code> (local network) ICE candidates received.
  1203. * @param {JSON} stats.connection.candidates.receiving.host.#index The Peer connection remote
  1204. * <code>"host"</code> (local network) ICE candidate.
  1205. * @param {String} stats.connection.candidates.receiving.host.#index.candidate The Peer connection remote
  1206. * <code>"host"</code> (local network) ICE candidate connection description.
  1207. * @param {String} stats.connection.candidates.receiving.host.#index.sdpMid The Peer connection remote
  1208. * <code>"host"</code> (local network) ICE candidate identifier based on the remote session description.
  1209. * @param {Number} stats.connection.candidates.receiving.host.#index.sdpMLineIndex The Peer connection remote
  1210. * <code>"host"</code> (local network) ICE candidate media description index (starting from <code>0</code>)
  1211. * based on the remote session description.
  1212. * @param {Array} stats.connection.candidates.receiving.srflx The Peer connection list of remote
  1213. * <code>"srflx"</code> (STUN) ICE candidates received.
  1214. * @param {JSON} stats.connection.candidates.receiving.srflx.#index The Peer connection remote
  1215. * <code>"srflx"</code> (STUN) ICE candidate.
  1216. * @param {String} stats.connection.candidates.receiving.srflx.#index.candidate The Peer connection remote
  1217. * <code>"srflx"</code> (STUN) ICE candidate connection description.
  1218. * @param {String} stats.connection.candidates.receiving.srflx.#index.sdpMid The Peer connection remote
  1219. * <code>"srflx"</code> (STUN) ICE candidate identifier based on the remote session description.
  1220. * @param {Number} stats.connection.candidates.receiving.srflx.#index.sdpMLineIndex The Peer connection remote
  1221. * <code>"srflx"</code> (STUN) ICE candidate media description index (starting from <code>0</code>)
  1222. * based on the remote session description.
  1223. * @param {Array} stats.connection.candidates.receiving.relay The Peer connection list of remote
  1224. * <code>"relay"</code> (TURN) ICE candidates received.
  1225. * @param {JSON} stats.connection.candidates.receiving.relay.#index The Peer connection remote
  1226. * <code>"relay"</code> (TURN) ICE candidate.
  1227. * @param {String} stats.connection.candidates.receiving.relay.#index.candidate The Peer connection remote
  1228. * <code>"relay"</code> (TURN) ICE candidate connection description.
  1229. * @param {String} stats.connection.candidates.receiving.relay.#index.sdpMid The Peer connection remote
  1230. * <code>"relay"</code> (TURN) ICE candidate identifier based on the remote session description.
  1231. * @param {Number} stats.connection.candidates.receiving.relay.#index.sdpMLineIndex The Peer connection remote
  1232. * <code>"relay"</code> (TURN) ICE candidate media description index (starting from <code>0</code>)
  1233. * based on the remote session description.
  1234. * @param {JSON} stats.connection.dataChannels The Peer connection list of Datachannel connections.
  1235. * @param {JSON} stats.connection.dataChannels.#channelName The Peer connection Datachannel connection stats.
  1236. * @param {String} stats.connection.dataChannels.#channelName.label The Peer connection Datachannel connection ID.
  1237. * @param {String} stats.connection.dataChannels.#channelName.readyState The Peer connection Datachannel connection readyState.
  1238. * [Rel: Skylink.DATA_CHANNEL_STATE]
  1239. * @param {String} stats.connection.dataChannels.#channelName.type The Peer connection Datachannel connection type.
  1240. * [Rel: Skylink.DATA_CHANNEL_TYPE]
  1241. * @param {String} stats.connection.dataChannels.#channelName.currentTransferId The Peer connection
  1242. * Datachannel connection current progressing transfer session ID.
  1243. * <small>Defined as <code>null</code> when there is currently no transfer session progressing on the Datachannel connection.</small>
  1244. * @param {String} stats.connection.dataChannels.#channelName.currentStreamId The Peer connection
  1245. * Datachannel connection current data streaming session ID.
  1246. * <small>Defined as <code>null</code> when there is currently no data streaming session on the Datachannel connection.</small>
  1247. * @param {JSON} stats.connection.constraints The constraints passed in when constructing the Peer connection object.
  1248. * @param {JSON} stats.connection.optional The optional constraints passed in when constructing the Peer connection object.
  1249. * @param {JSON} [stats.connection.sdpConstraints] The constraints passed in when creating Peer connection offer or answer.
  1250. * @param {Error} error The error object received.
  1251. * <small>Defined only when <code>state</code> payload is <code>RETRIEVE_ERROR</code>.</small>
  1252. * @for Skylink
  1253. * @since 0.6.14
  1254. */
  1255. getConnectionStatusStateChange: [],
  1256.  
  1257. /**
  1258. * Event triggered when <a href="#method_muteStream"><code>muteStream()</code> method</a> changes
  1259. * User Streams audio and video tracks muted status.
  1260. * @event localMediaMuted
  1261. * @param {JSON} mediaStatus The Streams muted settings.
  1262. * <small>This indicates the muted settings for both
  1263. * <a href="#method_getUserMedia"><code>getUserMedia()</code> Stream</a> and
  1264. * <a href="#method_shareScreen"><code>shareScreen()</code> Stream</a>.</small>
  1265. * @param {Boolean} mediaStatus.audioMuted The flag if all Streams audio tracks is muted or not.
  1266. * <small>If User's <code>peerInfo.settings.audio</code> is false, this will be defined as <code>true</code>.</small>
  1267. * @param {Boolean} mediaStatus.videoMuted The flag if all Streams video tracks is muted or not.
  1268. * <small>If User's <code>peerInfo.settings.video</code> is false, this will be defined as <code>true</code>.</small>
  1269. * @for Skylink
  1270. * @since 0.6.15
  1271. */
  1272. localMediaMuted: [],
  1273.  
  1274. /**
  1275. * <blockquote class="info">
  1276. * Learn more about how ICE works in this
  1277. * <a href="https://temasys.com.sg/ice-what-is-this-sorcery/">article here</a>.<br>
  1278. * Note that this event may not be triggered for MCU enabled Peer connections as ICE candidates
  1279. * may be received in the session description instead.
  1280. * </blockquote>
  1281. * Event triggered when remote ICE candidate processing state has changed when Peer is using trickle ICE.
  1282. * @event candidateProcessingState
  1283. * @param {String} state The ICE candidate processing state.
  1284. * [Rel: Skylink.CANDIDATE_PROCESSING_STATE]
  1285. * @param {String} peerId The Peer ID.
  1286. * @param {String} candidateId The remote ICE candidate session ID.
  1287. * <small>Note that this value is not related to WebRTC API but for identification of remote ICE candidate received.</small>
  1288. * @param {String} candidateType The remote ICE candidate type.
  1289. * <small>Expected values are <code>"host"</code> (local network), <code>"srflx"</code> (STUN) and <code>"relay"</code> (TURN).</small>
  1290. * @param {JSON} candidate The remote ICE candidate.
  1291. * @param {String} candidate.candidate The remote ICE candidate connection description.
  1292. * @param {String} candidate.sdpMid The remote ICE candidate identifier based on the remote session description.
  1293. * @param {Number} candidate.sdpMLineIndex The remote ICE candidate media description index
  1294. * (starting from <code>0</code>) based on the remote session description.
  1295. * @param {Error} [error] The error object.
  1296. * <small>Defined only when <code>state</code> is <code>DROPPED</code> or <code>PROCESS_ERROR</code>.</small>
  1297. * @for Skylink
  1298. * @since 0.6.16
  1299. */
  1300. candidateProcessingState: [],
  1301.  
  1302. /**
  1303. * <blockquote class="info">
  1304. * Learn more about how ICE works in this
  1305. * <a href="https://temasys.com.sg/ice-what-is-this-sorcery/">article here</a>.<br>
  1306. * Note that this event may not be triggered for MCU enabled Peer connections as ICE candidates
  1307. * may be received in the session description instead.
  1308. * </blockquote>
  1309. * Event triggered when all remote ICE candidates gathering has completed and been processed.
  1310. * @event candidatesGathered
  1311. * @param {String} peerId The Peer ID.
  1312. * @param {JSON} length The remote ICE candidates length.
  1313. * @param {Number} length.expected The expected total number of remote ICE candidates to be received.
  1314. * @param {Number} length.received The actual total number of remote ICE candidates received.
  1315. * @param {Number} length.processed The total number of remote ICE candidates processed.
  1316. * @for Skylink
  1317. * @since 0.6.18
  1318. */
  1319. candidatesGathered: []
  1320. };
  1321.  
  1322. /**
  1323. * Function that subscribes a listener to an event.
  1324. * @method on
  1325. * @param {String} eventName The event.
  1326. * @param {Function} callback The listener.
  1327. * <small>This will be invoked when event is triggered.</small>
  1328. * @example
  1329. * // Example 1: Subscribing to "peerJoined" event
  1330. * skylinkDemo.on("peerJoined", function (peerId, peerInfo, isSelf) {
  1331. * console.info("peerJoined event has been triggered with:", peerId, peerInfo, isSelf);
  1332. * });
  1333. * @for Skylink
  1334. * @since 0.1.0
  1335. */
  1336. Skylink.prototype.on = function(eventName, callback) {
  1337. if ('function' === typeof callback) {
  1338. this._EVENTS[eventName] = this._EVENTS[eventName] || [];
  1339. this._EVENTS[eventName].push(callback);
  1340. log.log([null, 'Event', eventName, 'Event is subscribed']);
  1341. } else {
  1342. log.error([null, 'Event', eventName, 'Provided parameter is not a function']);
  1343. }
  1344. };
  1345.  
  1346. /**
  1347. * Function that subscribes a listener to an event once.
  1348. * @method once
  1349. * @param {String} eventName The event.
  1350. * @param {Function} callback The listener.
  1351. * <small>This will be invoked once when event is triggered and conditional function is satisfied.</small>
  1352. * @param {Function} [condition] The conditional function that will be invoked when event is triggered.
  1353. * <small>Return <code>true</code> when invoked to satisfy condition.</small>
  1354. * <small>When not provided, the conditional function will always return <code>true</code>.</small>
  1355. * @param {Boolean} [fireAlways=false] The flag that indicates if <code>once()</code> should act like
  1356. * <code>on()</code> but only invoke listener only when conditional function is satisfied.
  1357. * @example
  1358. * // Example 1: Subscribing to "peerJoined" event that triggers without condition
  1359. * skylinkDemo.once("peerJoined", function (peerId, peerInfo, isSelf) {
  1360. * console.info("peerJoined event has been triggered once with:", peerId, peerInfo, isSelf);
  1361. * });
  1362. *
  1363. * // Example 2: Subscribing to "incomingStream" event that triggers with condition
  1364. * skylinkDemo.once("incomingStream", function (peerId, stream, isSelf, peerInfo) {
  1365. * console.info("incomingStream event has been triggered with User stream:", stream);
  1366. * }, function (peerId, peerInfo, isSelf) {
  1367. * return isSelf;
  1368. * });
  1369. *
  1370. * // Example 3: Subscribing to "dataTransferState" event that triggers always only when condition is satisfied
  1371. * skylinkDemo.once("dataTransferState", function (state, transferId, peerId, transferInfo) {
  1372. * console.info("Received data transfer from Peer:", transferInfo.data);
  1373. * }, function (state, transferId, peerId) {
  1374. * if (state === skylinkDemo.DATA_TRANSFER_STATE.UPLOAD_REQUEST) {
  1375. * skylinkDemo.acceptDataTransfer(peerId, transferId);
  1376. * }
  1377. * return state === skylinkDemo.DATA_TRANSFER_STATE.DOWNLOAD_COMPLETED;
  1378. * }, true);
  1379. * @for Skylink
  1380. * @since 0.5.4
  1381. */
  1382. Skylink.prototype.once = function(eventName, callback, condition, fireAlways) {
  1383. if (typeof condition === 'boolean') {
  1384. fireAlways = condition;
  1385. condition = null;
  1386. }
  1387. fireAlways = (typeof fireAlways === 'undefined' ? false : fireAlways);
  1388. condition = (typeof condition !== 'function') ? function () {
  1389. return true;
  1390. } : condition;
  1391.  
  1392. if (typeof callback === 'function') {
  1393. this._onceEvents[eventName] = this._onceEvents[eventName] || [];
  1394. this._onceEvents[eventName].push([callback, condition, fireAlways]);
  1395. log.log([null, 'Event', eventName, 'Event is subscribed on condition']);
  1396. } else {
  1397. log.error([null, 'Event', eventName, 'Provided callback is not a function']);
  1398. }
  1399. };
  1400.  
  1401. /**
  1402. * Function that unsubscribes listeners from an event.
  1403. * @method off
  1404. * @param {String} [eventName] The event.
  1405. * - When not provided, all listeners to all events will be unsubscribed.
  1406. * @param {Function} [callback] The listener to unsubscribe.
  1407. * - When not provided, all listeners associated to the event will be unsubscribed.
  1408. * @example
  1409. * // Example 1: Unsubscribe all "peerJoined" event
  1410. * skylinkDemo.off("peerJoined");
  1411. *
  1412. * // Example 2: Unsubscribe only one listener from "peerJoined event"
  1413. * var pJListener = function (peerId, peerInfo, isSelf) {
  1414. * console.info("peerJoined event has been triggered with:", peerId, peerInfo, isSelf);
  1415. * };
  1416. *
  1417. * skylinkDemo.off("peerJoined", pJListener);
  1418. * @for Skylink
  1419. * @since 0.5.5
  1420. */
  1421. Skylink.prototype.off = function(eventName, callback) {
  1422. if (!(eventName && typeof eventName === 'string')) {
  1423. this._EVENTS = {};
  1424. this._onceEvents = {};
  1425. } else {
  1426. if (callback === undefined) {
  1427. this._EVENTS[eventName] = [];
  1428. this._onceEvents[eventName] = [];
  1429. log.log([null, 'Event', eventName, 'All events are unsubscribed']);
  1430. return;
  1431. }
  1432. var arr = this._EVENTS[eventName] || [];
  1433. var once = this._onceEvents[eventName] || [];
  1434.  
  1435. // unsubscribe events that is triggered always
  1436. for (var i = 0; i < arr.length; i++) {
  1437. if (arr[i] === callback) {
  1438. log.log([null, 'Event', eventName, 'Event is unsubscribed']);
  1439. arr.splice(i, 1);
  1440. break;
  1441. }
  1442. }
  1443. // unsubscribe events fired only once
  1444. if(once !== undefined) {
  1445. for (var j = 0; j < once.length; j++) {
  1446. if (once[j][0] === callback) {
  1447. log.log([null, 'Event', eventName, 'One-time Event is unsubscribed']);
  1448. once.splice(j, 1);
  1449. break;
  1450. }
  1451. }
  1452. }
  1453. }
  1454. };
  1455.  
  1456. /**
  1457. * Function that triggers an event.
  1458. * The rest of the parameters after the <code>eventName</code> parameter is considered as the event parameter payloads.
  1459. * @method _trigger
  1460. * @private
  1461. * @for Skylink
  1462. * @since 0.1.0
  1463. */
  1464. Skylink.prototype._trigger = function(eventName) {
  1465. //convert the arguments into an array
  1466. var args = Array.prototype.slice.call(arguments);
  1467. var arr = this._EVENTS[eventName];
  1468. var once = this._onceEvents[eventName] || null;
  1469. args.shift(); //Omit the first argument since it's the event name
  1470. if (arr) {
  1471. // for events subscribed forever
  1472. for (var i = 0; i < arr.length; i++) {
  1473. try {
  1474. log.log([null, 'Event', eventName, 'Event is fired']);
  1475. if(arr[i].apply(this, args) === false) {
  1476. break;
  1477. }
  1478. } catch(error) {
  1479. log.error([null, 'Event', eventName, 'Exception occurred in event:'], error);
  1480. throw error;
  1481. }
  1482. }
  1483. }
  1484. if (once){
  1485. // for events subscribed on once
  1486. for (var j = 0; j < once.length; j++) {
  1487. if (once[j][1].apply(this, args) === true) {
  1488. log.log([null, 'Event', eventName, 'Condition is met. Firing event']);
  1489. if(once[j][0].apply(this, args) === false) {
  1490. break;
  1491. }
  1492. if (once[j] && !once[j][2]) {
  1493. log.log([null, 'Event', eventName, 'Removing event after firing once']);
  1494. once.splice(j, 1);
  1495. //After removing current element, the next element should be element of the same index
  1496. j--;
  1497. }
  1498. } else {
  1499. log.log([null, 'Event', eventName, 'Condition is still not met. ' +
  1500. 'Holding event from being fired']);
  1501. }
  1502. }
  1503. }
  1504. log.log([null, 'Event', eventName, 'Event is triggered']);
  1505. };
  1506.  
  1507.  
  1508.  
  1509. /**
  1510. * Function that checks if the current state condition is met before subscribing
  1511. * event handler to wait for condition to be fulfilled.
  1512. * @method _condition
  1513. * @private
  1514. * @for Skylink
  1515. * @since 0.5.5
  1516. */
  1517. Skylink.prototype._condition = function(eventName, callback, checkFirst, condition, fireAlways) {
  1518. if (typeof condition === 'boolean') {
  1519. fireAlways = condition;
  1520. condition = null;
  1521. }
  1522. if (typeof callback === 'function' && typeof checkFirst === 'function') {
  1523. if (checkFirst()) {
  1524. log.log([null, 'Event', eventName, 'First condition is met. Firing callback']);
  1525. callback();
  1526. return;
  1527. }
  1528. log.log([null, 'Event', eventName, 'First condition is not met. Subscribing to event']);
  1529. this.once(eventName, callback, condition, fireAlways);
  1530. } else {
  1531. log.error([null, 'Event', eventName, 'Provided callback or checkFirst is not a function']);
  1532. }
  1533. };
  1534.  
  1535. /**
  1536. * Function that starts an interval check to wait for a condition to be resolved.
  1537. * @method _wait
  1538. * @private
  1539. * @for Skylink
  1540. * @since 0.5.5
  1541. */
  1542. Skylink.prototype._wait = function(callback, condition, intervalTime, fireAlways) {
  1543. fireAlways = (typeof fireAlways === 'undefined' ? false : fireAlways);
  1544. if (typeof callback === 'function' && typeof condition === 'function') {
  1545. if (condition()) {
  1546. log.log([null, 'Event', null, 'Condition is met. Firing callback']);
  1547. callback();
  1548. return;
  1549. }
  1550. log.log([null, 'Event', null, 'Condition is not met. Doing a check.']);
  1551.  
  1552. intervalTime = (typeof intervalTime === 'number') ? intervalTime : 50;
  1553.  
  1554. var doWait = setInterval(function () {
  1555. if (condition()) {
  1556. log.log([null, 'Event', null, 'Condition is met after waiting. Firing callback']);
  1557. if (!fireAlways){
  1558. clearInterval(doWait);
  1559. }
  1560. callback();
  1561. }
  1562. }, intervalTime);
  1563. } else {
  1564. if (typeof callback !== 'function'){
  1565. log.error([null, 'Event', null, 'Provided callback is not a function']);
  1566. }
  1567. if (typeof condition !== 'function'){
  1568. log.error([null, 'Event', null, 'Provided condition is not a function']);
  1569. }
  1570. }
  1571. };
  1572.  
  1573. /**
  1574. * Function that throttles a method function to prevent multiple invokes over a specified amount of time.
  1575. * Returns a function to be invoked <code>._throttle(fn, 1000)()</code> to make throttling functionality work.
  1576. * @method _throttle
  1577. * @private
  1578. * @for Skylink
  1579. * @since 0.5.8
  1580. */
  1581. Skylink.prototype._throttle = function(func, prop, wait){
  1582. var self = this;
  1583. var now = (new Date()).getTime();
  1584.  
  1585. if (!(self._timestamp[prop] && ((now - self._timestamp[prop]) < wait))) {
  1586. func(true);
  1587. self._timestamp[prop] = now;
  1588. } else {
  1589. func(false);
  1590. }
  1591. };