Rocket.Chat.RealTime.API.RxJS
v2.1.1
RXJS v6을 사용한 Chat의 실시간 API 방법을 사용하기위한 추상화
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 (methodName, ... params) | Rocket.Chat Realtime API에서 메소드 호출 결과에 관찰 가능한 반환 |
| sendmessage (jsonobject) | JSON 객체를 API 서버로 보냅니다 |
| OnMessage (message => console.log (메시지)) | 서버에서 전송 된 메시지를 구독합니다 |
| onerror (error => console.error (오류)) | 오류가 발생합니다. |
| oncompletion (() => console.info ( "완료")) | WebSocket 연결에서 완료를 구독합니다 |
| 구독 (MessageHandler, ErrorHandler, WompletionHandler) | 세 가지 즉, 메시지, 오류 및 완료를 모두 구독합니다. |
| getObservable () | WebSocket 연결을 실시간 API에 반환합니다. |
| 연결 해제 () | 클라이언트와 실시간 API 간의 WebSocket 연결을 분리하십시오 |