client.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. <!doctype html>
  2. <html class="default no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>Client | @urtc/sdk-web</title>
  7. <meta name="description" content="Documentation for @urtc/sdk-web">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link rel="stylesheet" href="../assets/css/main.css">
  10. </head>
  11. <body>
  12. <header>
  13. <div class="tsd-page-toolbar">
  14. <div class="container">
  15. <div class="table-wrap">
  16. <div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
  17. <div class="field">
  18. <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
  19. <input id="tsd-search-field" type="text" />
  20. </div>
  21. <ul class="results">
  22. <li class="state loading">Preparing search index...</li>
  23. <li class="state failure">The search index is not available</li>
  24. </ul>
  25. <a href="../index.html" class="title">@urtc/sdk-web</a>
  26. </div>
  27. <div class="table-cell" id="tsd-widgets">
  28. <div id="tsd-filter">
  29. <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
  30. <div class="tsd-filter-group">
  31. <div class="tsd-select" id="tsd-filter-visibility">
  32. <span class="tsd-select-label">All</span>
  33. <ul class="tsd-select-list">
  34. <li data-value="public">Public</li>
  35. <li data-value="protected">Public/Protected</li>
  36. <li data-value="private" class="selected">All</li>
  37. </ul>
  38. </div>
  39. <input type="checkbox" id="tsd-filter-inherited" checked />
  40. <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
  41. <input type="checkbox" id="tsd-filter-externals" checked />
  42. <label class="tsd-widget" for="tsd-filter-externals">Externals</label>
  43. </div>
  44. </div>
  45. <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="tsd-page-title">
  51. <div class="container">
  52. <ul class="tsd-breadcrumb">
  53. <li>
  54. <a href="../index.html">Globals</a>
  55. </li>
  56. <li>
  57. <a href="client.html">Client</a>
  58. </li>
  59. </ul>
  60. <h1>Class Client</h1>
  61. </div>
  62. </div>
  63. </header>
  64. <div class="container container-main">
  65. <div class="row">
  66. <div class="col-8 col-content">
  67. <section class="tsd-panel tsd-comment">
  68. <div class="tsd-comment tsd-typography">
  69. <div class="lead">
  70. <p>URTC 客户端,可进行加入、离开房间,发布、订阅流等操作。</p>
  71. </div>
  72. </div>
  73. </section>
  74. <section class="tsd-panel tsd-hierarchy">
  75. <h3>Hierarchy</h3>
  76. <ul class="tsd-hierarchy">
  77. <li>
  78. <span class="target">Client</span>
  79. </li>
  80. </ul>
  81. </section>
  82. <section class="tsd-panel-group tsd-index-group">
  83. <h2>Index</h2>
  84. <section class="tsd-panel tsd-index-panel">
  85. <div class="tsd-index-content">
  86. <section class="tsd-index-section tsd-is-external">
  87. <h3>Methods</h3>
  88. <ul class="tsd-index-list">
  89. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#getlocalstreams" class="tsd-kind-icon">get<wbr>Local<wbr>Streams</a></li>
  90. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#getremotestreams" class="tsd-kind-icon">get<wbr>Remote<wbr>Streams</a></li>
  91. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#getremoteusers" class="tsd-kind-icon">get<wbr>Remote<wbr>Users</a></li>
  92. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#join" class="tsd-kind-icon">join</a></li>
  93. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#leave" class="tsd-kind-icon">leave</a></li>
  94. <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external"><a href="client.html#off" class="tsd-kind-icon">off</a></li>
  95. <li class="tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external"><a href="client.html#on" class="tsd-kind-icon">on</a></li>
  96. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#publish" class="tsd-kind-icon">publish</a></li>
  97. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#setrole" class="tsd-kind-icon">set<wbr>Role</a></li>
  98. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#subscribe" class="tsd-kind-icon">subscribe</a></li>
  99. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#unpublish" class="tsd-kind-icon">unpublish</a></li>
  100. <li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="client.html#unsubscribe" class="tsd-kind-icon">unsubscribe</a></li>
  101. </ul>
  102. </section>
  103. </div>
  104. </section>
  105. </section>
  106. <section class="tsd-panel-group tsd-member-group tsd-is-external">
  107. <h2>Methods</h2>
  108. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  109. <a name="getlocalstreams" class="tsd-anchor"></a>
  110. <h3>get<wbr>Local<wbr>Streams</h3>
  111. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  112. <li class="tsd-signature tsd-kind-icon">get<wbr>Local<wbr>Streams<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="localstream.html" class="tsd-signature-type">LocalStream</a><span class="tsd-signature-symbol">[]</span></li>
  113. </ul>
  114. <ul class="tsd-descriptions">
  115. <li class="tsd-description">
  116. <aside class="tsd-sources">
  117. </aside>
  118. <div class="tsd-comment tsd-typography">
  119. <div class="lead">
  120. <p>获取当前 Client 已发布的本地流</p>
  121. </div>
  122. <dl class="tsd-comment-tags">
  123. <dt>example</dt>
  124. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> localStreams = client.getLocalStreams();</code></pre>
  125. </dd>
  126. </dl>
  127. </div>
  128. <h4 class="tsd-returns-title">Returns <a href="localstream.html" class="tsd-signature-type">LocalStream</a><span class="tsd-signature-symbol">[]</span></h4>
  129. </li>
  130. </ul>
  131. </section>
  132. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  133. <a name="getremotestreams" class="tsd-anchor"></a>
  134. <h3>get<wbr>Remote<wbr>Streams</h3>
  135. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  136. <li class="tsd-signature tsd-kind-icon">get<wbr>Remote<wbr>Streams<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="remotestream.html" class="tsd-signature-type">RemoteStream</a><span class="tsd-signature-symbol">[]</span></li>
  137. </ul>
  138. <ul class="tsd-descriptions">
  139. <li class="tsd-description">
  140. <aside class="tsd-sources">
  141. </aside>
  142. <div class="tsd-comment tsd-typography">
  143. <div class="lead">
  144. <p>获取当前 Client 已接收到的远端流(包含已订阅或未订阅的远端流)</p>
  145. </div>
  146. <dl class="tsd-comment-tags">
  147. <dt>example</dt>
  148. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> remoteStreams = client.getRemoteStreams();</code></pre>
  149. </dd>
  150. </dl>
  151. </div>
  152. <h4 class="tsd-returns-title">Returns <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a><span class="tsd-signature-symbol">[]</span></h4>
  153. </li>
  154. </ul>
  155. </section>
  156. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  157. <a name="getremoteusers" class="tsd-anchor"></a>
  158. <h3>get<wbr>Remote<wbr>Users</h3>
  159. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  160. <li class="tsd-signature tsd-kind-icon">get<wbr>Remote<wbr>Users<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="user.html" class="tsd-signature-type">User</a><span class="tsd-signature-symbol">[]</span></li>
  161. </ul>
  162. <ul class="tsd-descriptions">
  163. <li class="tsd-description">
  164. <aside class="tsd-sources">
  165. </aside>
  166. <div class="tsd-comment tsd-typography">
  167. <div class="lead">
  168. <p>获取远端用户信息</p>
  169. </div>
  170. <dl class="tsd-comment-tags">
  171. <dt>example</dt>
  172. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> users = client.getRemoteUsers();</code></pre>
  173. </dd>
  174. </dl>
  175. </div>
  176. <h4 class="tsd-returns-title">Returns <a href="user.html" class="tsd-signature-type">User</a><span class="tsd-signature-symbol">[]</span></h4>
  177. </li>
  178. </ul>
  179. </section>
  180. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  181. <a name="join" class="tsd-anchor"></a>
  182. <h3>join</h3>
  183. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  184. <li class="tsd-signature tsd-kind-icon">join<span class="tsd-signature-symbol">(</span>roomId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, userId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, opts<span class="tsd-signature-symbol">?: </span><a href="../interfaces/joinoptions.html" class="tsd-signature-type">JoinOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  185. </ul>
  186. <ul class="tsd-descriptions">
  187. <li class="tsd-description">
  188. <aside class="tsd-sources">
  189. </aside>
  190. <div class="tsd-comment tsd-typography">
  191. <div class="lead">
  192. <p>加入房间</p>
  193. </div>
  194. <dl class="tsd-comment-tags">
  195. <dt>example</dt>
  196. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> remoteStreams = client.getRemoteStreams();
  197. client
  198. .join(<span class="hljs-string">&#x27;roomId&#x27;</span>, <span class="hljs-string">&#x27;userId&#x27;</span>, <span class="hljs-string">&#x27;token-xxx&#x27;</span>)
  199. .then(<span class="hljs-function">() =&gt;</span> {
  200. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`加入房间成功`</span>);
  201. <span class="hljs-comment">// client.publish(localStream);</span>
  202. })
  203. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  204. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`加入房间失败 <span class="hljs-subst">${err}</span>`</span>);
  205. });</code></pre>
  206. </dd>
  207. <dt>reject</dt>
  208. <dd><p><a href="rtcerror.html">RtcError</a></p>
  209. </dd>
  210. </dl>
  211. </div>
  212. <h4 class="tsd-parameters-title">Parameters</h4>
  213. <ul class="tsd-parameters">
  214. <li>
  215. <h5>roomId: <span class="tsd-signature-type">string</span></h5>
  216. <div class="tsd-comment tsd-typography">
  217. <p>房间ID</p>
  218. </div>
  219. </li>
  220. <li>
  221. <h5>userId: <span class="tsd-signature-type">string</span></h5>
  222. <div class="tsd-comment tsd-typography">
  223. <p>用户ID</p>
  224. </div>
  225. </li>
  226. <li>
  227. <h5>token: <span class="tsd-signature-type">string</span></h5>
  228. <div class="tsd-comment tsd-typography">
  229. <p>由 AppId,AppKey,RoomId,UserId 生成的令牌</p>
  230. </div>
  231. </li>
  232. <li>
  233. <h5><span class="tsd-flag ts-flagOptional">Optional</span> opts: <a href="../interfaces/joinoptions.html" class="tsd-signature-type">JoinOptions</a></h5>
  234. <div class="tsd-comment tsd-typography">
  235. <p>其他选项</p>
  236. </div>
  237. </li>
  238. </ul>
  239. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  240. </li>
  241. </ul>
  242. </section>
  243. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  244. <a name="leave" class="tsd-anchor"></a>
  245. <h3>leave</h3>
  246. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  247. <li class="tsd-signature tsd-kind-icon">leave<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  248. </ul>
  249. <ul class="tsd-descriptions">
  250. <li class="tsd-description">
  251. <aside class="tsd-sources">
  252. </aside>
  253. <div class="tsd-comment tsd-typography">
  254. <div class="lead">
  255. <p>离开房间</p>
  256. </div>
  257. <dl class="tsd-comment-tags">
  258. <dt>example</dt>
  259. <dd><pre><code class="language-js">client
  260. .leave()
  261. .then(<span class="hljs-function">() =&gt;</span> {
  262. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`离开房间成功`</span>);
  263. })
  264. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  265. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`离开房间失败 <span class="hljs-subst">${err}</span>`</span>);
  266. });</code></pre>
  267. </dd>
  268. </dl>
  269. </div>
  270. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  271. </li>
  272. </ul>
  273. </section>
  274. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  275. <a name="off" class="tsd-anchor"></a>
  276. <h3>off</h3>
  277. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  278. <li class="tsd-signature tsd-kind-icon">off&lt;T&gt;<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, listener<span class="tsd-signature-symbol">?: </span><a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  279. </ul>
  280. <ul class="tsd-descriptions">
  281. <li class="tsd-description">
  282. <aside class="tsd-sources">
  283. </aside>
  284. <div class="tsd-comment tsd-typography">
  285. <div class="lead">
  286. <p>取消监听 Client 对象的事件</p>
  287. </div>
  288. <dl class="tsd-comment-tags">
  289. <dt>example</dt>
  290. <dd><pre><code class="language-js">client.off(<span class="hljs-string">&#x27;stream-added&#x27;</span>, handleStreamAdded);</code></pre>
  291. <p><strong>特别地,一次性取消对所有事件的监听</strong></p>
  292. </dd>
  293. <dt>example</dt>
  294. <dd><pre><code class="language-js">client.off(<span class="hljs-string">&#x27;*&#x27;</span>);</code></pre>
  295. </dd>
  296. <dt>throws</dt>
  297. <dd><p><a href="rtcerror.html">RtcError</a></p>
  298. </dd>
  299. </dl>
  300. </div>
  301. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  302. <ul class="tsd-type-parameters">
  303. <li>
  304. <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">"*"</span></h4>
  305. </li>
  306. </ul>
  307. <h4 class="tsd-parameters-title">Parameters</h4>
  308. <ul class="tsd-parameters">
  309. <li>
  310. <h5>type: <span class="tsd-signature-type">T</span></h5>
  311. <div class="tsd-comment tsd-typography">
  312. <p>事件类型,特别的,可以使用 * 来一次性取消对所有事件的监听</p>
  313. </div>
  314. </li>
  315. <li>
  316. <h5><span class="tsd-flag ts-flagOptional">Optional</span> listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
  317. <div class="tsd-comment tsd-typography">
  318. <p>事件监听函数</p>
  319. </div>
  320. </li>
  321. </ul>
  322. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  323. </li>
  324. </ul>
  325. </section>
  326. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  327. <a name="on" class="tsd-anchor"></a>
  328. <h3>on</h3>
  329. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  330. <li class="tsd-signature tsd-kind-icon">on&lt;T&gt;<span class="tsd-signature-symbol">(</span>type<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">T</span>, listener<span class="tsd-signature-symbol">: </span><a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  331. </ul>
  332. <ul class="tsd-descriptions">
  333. <li class="tsd-description">
  334. <aside class="tsd-sources">
  335. </aside>
  336. <div class="tsd-comment tsd-typography">
  337. <div class="lead">
  338. <p>监听 Client 对象的事件</p>
  339. </div>
  340. <dl class="tsd-comment-tags">
  341. <dt>example</dt>
  342. <dd><pre><code class="language-js"><span class="hljs-keyword">const</span> handleStreamAdded = <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  343. client
  344. .subscribe(event.data)
  345. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  346. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`订阅失败 <span class="hljs-subst">${err}</span>`</span>);
  347. });
  348. }
  349. client.on(<span class="hljs-string">&#x27;stream-added&#x27;</span>, handleStreamAdded);</code></pre>
  350. </dd>
  351. <dt>throws</dt>
  352. <dd><p><a href="rtcerror.html">RtcError</a></p>
  353. </dd>
  354. </dl>
  355. </div>
  356. <h4 class="tsd-type-parameters-title">Type parameters</h4>
  357. <ul class="tsd-type-parameters">
  358. <li>
  359. <h4>T<span class="tsd-signature-symbol">: </span><a href="../index.html#rtceventtype" class="tsd-signature-type">RtcEventType</a></h4>
  360. </li>
  361. </ul>
  362. <h4 class="tsd-parameters-title">Parameters</h4>
  363. <ul class="tsd-parameters">
  364. <li>
  365. <h5>type: <span class="tsd-signature-type">T</span></h5>
  366. <div class="tsd-comment tsd-typography">
  367. <p>事件类型</p>
  368. </div>
  369. </li>
  370. <li>
  371. <h5>listener: <a href="../interfaces/listener.html" class="tsd-signature-type">Listener</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
  372. <div class="tsd-comment tsd-typography">
  373. <p>事件监听函数</p>
  374. </div>
  375. </li>
  376. </ul>
  377. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  378. </li>
  379. </ul>
  380. </section>
  381. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  382. <a name="publish" class="tsd-anchor"></a>
  383. <h3>publish</h3>
  384. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  385. <li class="tsd-signature tsd-kind-icon">publish<span class="tsd-signature-symbol">(</span>stream<span class="tsd-signature-symbol">: </span><a href="localstream.html" class="tsd-signature-type">LocalStream</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  386. </ul>
  387. <ul class="tsd-descriptions">
  388. <li class="tsd-description">
  389. <aside class="tsd-sources">
  390. </aside>
  391. <div class="tsd-comment tsd-typography">
  392. <div class="lead">
  393. <p>发布一条本地流</p>
  394. </div>
  395. <dl class="tsd-comment-tags">
  396. <dt>example</dt>
  397. <dd><pre><code class="language-js">client
  398. .publish(localStream)
  399. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  400. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`发布失败 <span class="hljs-subst">${err}</span>`</span>);
  401. });</code></pre>
  402. </dd>
  403. <dt>reject</dt>
  404. <dd><p><a href="rtcerror.html">RtcError</a></p>
  405. </dd>
  406. </dl>
  407. </div>
  408. <h4 class="tsd-parameters-title">Parameters</h4>
  409. <ul class="tsd-parameters">
  410. <li>
  411. <h5>stream: <a href="localstream.html" class="tsd-signature-type">LocalStream</a></h5>
  412. <div class="tsd-comment tsd-typography">
  413. <p>需要被发布的本地流</p>
  414. </div>
  415. </li>
  416. </ul>
  417. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  418. </li>
  419. </ul>
  420. </section>
  421. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  422. <a name="setrole" class="tsd-anchor"></a>
  423. <h3>set<wbr>Role</h3>
  424. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  425. <li class="tsd-signature tsd-kind-icon">set<wbr>Role<span class="tsd-signature-symbol">(</span>role<span class="tsd-signature-symbol">: </span><a href="../index.html#roletype" class="tsd-signature-type">RoleType</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
  426. </ul>
  427. <ul class="tsd-descriptions">
  428. <li class="tsd-description">
  429. <aside class="tsd-sources">
  430. </aside>
  431. <div class="tsd-comment tsd-typography">
  432. <div class="lead">
  433. <p>修改用户角色</p>
  434. </div>
  435. <dl class="tsd-comment-tags">
  436. <dt>example</dt>
  437. <dd><pre><code class="language-js">client.setRole(<span class="hljs-string">&#x27;push&#x27;</span>);</code></pre>
  438. </dd>
  439. <dt>throws</dt>
  440. <dd><p><a href="rtcerror.html">RtcError</a></p>
  441. </dd>
  442. </dl>
  443. </div>
  444. <h4 class="tsd-parameters-title">Parameters</h4>
  445. <ul class="tsd-parameters">
  446. <li>
  447. <h5>role: <a href="../index.html#roletype" class="tsd-signature-type">RoleType</a></h5>
  448. <div class="tsd-comment tsd-typography">
  449. <p>用户角色</p>
  450. </div>
  451. </li>
  452. </ul>
  453. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
  454. </li>
  455. </ul>
  456. </section>
  457. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  458. <a name="subscribe" class="tsd-anchor"></a>
  459. <h3>subscribe</h3>
  460. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  461. <li class="tsd-signature tsd-kind-icon">subscribe<span class="tsd-signature-symbol">(</span>stream<span class="tsd-signature-symbol">: </span><a href="remotestream.html" class="tsd-signature-type">RemoteStream</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  462. </ul>
  463. <ul class="tsd-descriptions">
  464. <li class="tsd-description">
  465. <aside class="tsd-sources">
  466. </aside>
  467. <div class="tsd-comment tsd-typography">
  468. <div class="lead">
  469. <p>订阅一条远端流</p>
  470. </div>
  471. <dl class="tsd-comment-tags">
  472. <dt>example</dt>
  473. <dd><pre><code class="language-js">client
  474. .subscribe(remoteStream)
  475. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  476. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`订阅失败 <span class="hljs-subst">${err}</span>`</span>);
  477. });</code></pre>
  478. </dd>
  479. <dt>reject</dt>
  480. <dd><p><a href="rtcerror.html">RtcError</a></p>
  481. </dd>
  482. </dl>
  483. </div>
  484. <h4 class="tsd-parameters-title">Parameters</h4>
  485. <ul class="tsd-parameters">
  486. <li>
  487. <h5>stream: <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a></h5>
  488. <div class="tsd-comment tsd-typography">
  489. <p>需要被订阅的远端流</p>
  490. </div>
  491. </li>
  492. </ul>
  493. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  494. </li>
  495. </ul>
  496. </section>
  497. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  498. <a name="unpublish" class="tsd-anchor"></a>
  499. <h3>unpublish</h3>
  500. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  501. <li class="tsd-signature tsd-kind-icon">unpublish<span class="tsd-signature-symbol">(</span>stream<span class="tsd-signature-symbol">: </span><a href="localstream.html" class="tsd-signature-type">LocalStream</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  502. </ul>
  503. <ul class="tsd-descriptions">
  504. <li class="tsd-description">
  505. <aside class="tsd-sources">
  506. </aside>
  507. <div class="tsd-comment tsd-typography">
  508. <div class="lead">
  509. <p>取消发布一条本地流</p>
  510. </div>
  511. <dl class="tsd-comment-tags">
  512. <dt>example</dt>
  513. <dd><pre><code class="language-js">client
  514. .unpublish(localStream)
  515. .then(<span class="hljs-function">() =&gt;</span> {
  516. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&#x27;取消发布成功&#x27;</span>);
  517. <span class="hljs-comment">// localStream.destroy();</span>
  518. })
  519. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  520. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`取消发布失败 <span class="hljs-subst">${err}</span>`</span>);
  521. });</code></pre>
  522. </dd>
  523. <dt>reject</dt>
  524. <dd><p><a href="rtcerror.html">RtcError</a></p>
  525. </dd>
  526. </dl>
  527. </div>
  528. <h4 class="tsd-parameters-title">Parameters</h4>
  529. <ul class="tsd-parameters">
  530. <li>
  531. <h5>stream: <a href="localstream.html" class="tsd-signature-type">LocalStream</a></h5>
  532. <div class="tsd-comment tsd-typography">
  533. <p>需要取消发布的本地流</p>
  534. </div>
  535. </li>
  536. </ul>
  537. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  538. </li>
  539. </ul>
  540. </section>
  541. <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
  542. <a name="unsubscribe" class="tsd-anchor"></a>
  543. <h3>unsubscribe</h3>
  544. <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
  545. <li class="tsd-signature tsd-kind-icon">unsubscribe<span class="tsd-signature-symbol">(</span>stream<span class="tsd-signature-symbol">: </span><a href="remotestream.html" class="tsd-signature-type">RemoteStream</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></li>
  546. </ul>
  547. <ul class="tsd-descriptions">
  548. <li class="tsd-description">
  549. <aside class="tsd-sources">
  550. </aside>
  551. <div class="tsd-comment tsd-typography">
  552. <div class="lead">
  553. <p>取消订阅一条远端流</p>
  554. </div>
  555. <dl class="tsd-comment-tags">
  556. <dt>example</dt>
  557. <dd><pre><code class="language-js">client
  558. .unsubscribe(remoteStream)
  559. .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
  560. <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`取消订阅失败 <span class="hljs-subst">${err}</span>`</span>);
  561. });</code></pre>
  562. </dd>
  563. <dt>reject</dt>
  564. <dd><p><a href="rtcerror.html">RtcError</a></p>
  565. </dd>
  566. </dl>
  567. </div>
  568. <h4 class="tsd-parameters-title">Parameters</h4>
  569. <ul class="tsd-parameters">
  570. <li>
  571. <h5>stream: <a href="remotestream.html" class="tsd-signature-type">RemoteStream</a></h5>
  572. <div class="tsd-comment tsd-typography">
  573. <p>需要取消订阅的远端流</p>
  574. </div>
  575. </li>
  576. </ul>
  577. <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</span></h4>
  578. </li>
  579. </ul>
  580. </section>
  581. </section>
  582. </div>
  583. <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
  584. <nav class="tsd-navigation primary">
  585. <ul>
  586. <li class="globals ">
  587. <a href="../index.html"><em>Globals</em></a>
  588. </li>
  589. </ul>
  590. </nav>
  591. <nav class="tsd-navigation secondary menu-sticky">
  592. <ul class="before-current">
  593. </ul>
  594. <ul class="current">
  595. <li class="current tsd-kind-class tsd-is-external">
  596. <a href="client.html" class="tsd-kind-icon">Client</a>
  597. <ul>
  598. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  599. <a href="client.html#getlocalstreams" class="tsd-kind-icon">get<wbr>Local<wbr>Streams</a>
  600. </li>
  601. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  602. <a href="client.html#getremotestreams" class="tsd-kind-icon">get<wbr>Remote<wbr>Streams</a>
  603. </li>
  604. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  605. <a href="client.html#getremoteusers" class="tsd-kind-icon">get<wbr>Remote<wbr>Users</a>
  606. </li>
  607. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  608. <a href="client.html#join" class="tsd-kind-icon">join</a>
  609. </li>
  610. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  611. <a href="client.html#leave" class="tsd-kind-icon">leave</a>
  612. </li>
  613. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  614. <a href="client.html#off" class="tsd-kind-icon">off</a>
  615. </li>
  616. <li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-external">
  617. <a href="client.html#on" class="tsd-kind-icon">on</a>
  618. </li>
  619. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  620. <a href="client.html#publish" class="tsd-kind-icon">publish</a>
  621. </li>
  622. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  623. <a href="client.html#setrole" class="tsd-kind-icon">set<wbr>Role</a>
  624. </li>
  625. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  626. <a href="client.html#subscribe" class="tsd-kind-icon">subscribe</a>
  627. </li>
  628. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  629. <a href="client.html#unpublish" class="tsd-kind-icon">unpublish</a>
  630. </li>
  631. <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
  632. <a href="client.html#unsubscribe" class="tsd-kind-icon">unsubscribe</a>
  633. </li>
  634. </ul>
  635. </li>
  636. </ul>
  637. <ul class="after-current">
  638. </ul>
  639. </nav>
  640. </div>
  641. </div>
  642. </div>
  643. <footer class="with-border-bottom">
  644. <div class="container">
  645. <h2>Legend</h2>
  646. <div class="tsd-legend-group">
  647. </div>
  648. </div>
  649. </footer>
  650. <div class="container tsd-generator">
  651. <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
  652. </div>
  653. <div class="overlay"></div>
  654. <script src="../assets/js/main.js"></script>
  655. </body>
  656. </html>