Rocket.Chat.RealTime.API.RxJS
v2.1.1
用於利用Rocket.Chat的實時API方法的抽象使用RXJS V6
npm install --save rocket.chat.realtime.api.rxjs
用於rxjs v5版本的軟件包
npm install --save [email protected]
import { RealTimeAPI } from "rocket.chat.realtime.api.rxjs";
const realTimeAPI = new RealTimeAPI("wss://demo.rocket.chat/websocket");
// Provide, URL to the Rocket.Chat's Realtime API.
realTimeAPI.keepAlive().subscribe();
// Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive.
const auth = realTimeAPI.login(USERNAME, PASSWORD);
// Creating Observable
//Now subscribing the observable
auth.subscribe(
(data) => console.log(data),
(err) => console.log(err),
() => console.log('completed'));
...
...
// Use any of the methods implmented in the package.
| 方法 | 功能 |
|---|---|
| ConnectToserver() | 啟動到服務器連接到實時API。通過服務器的響應返回可觀察的 |
| keepalive() | 返回可觀察到的訂閱,該訂閱對實時API發送的“ ping”響應“ pong”。保持連接的活力。 |
| 登錄(用戶名,密碼) | 可觀察到實時API的結果/響應的返回。 |
| loginwithauthtoken(authtoken) | 可觀察到實時API的結果/響應的返回。 |
| loginwithoauth(CredToken,CredSecret) | 可觀察到實時API的結果/響應的返回。 |
| callmethod(方法名稱,...參數) | 返回可觀察到的方法是來自Rocket.Chat實時API的方法的結果 |
| sendmessage(jsonobject) | 將JSON對象發送到API服務器 |
| onMessage(消息=> console.log(message)) | 訂閱從服務器發送的消息 |
| OnError(error => console.error(error)) | 訂閱錯誤。 |
| oncompletion(()=> console.info(“ pountty”)) | 在WebSocket連接上訂閱完成 |
| 訂閱(MessageHandler,ErryHandler,plotehhandler) | 訂閱所有三個IE-消息,錯誤和完成 |
| getObservable() | 返回可觀察到的Websocket連接到實時API的連接 |
| 斷開() | 斷開客戶端和實時API之間的WebSocket連接 |