From 0b220a35aa36616adf977ad06d1901c3341116a8 Mon Sep 17 00:00:00 2001 From: Viraj Trivedi Date: Thu, 22 Jun 2017 18:32:27 +0530 Subject: [PATCH 1/3] Readme Updated, Initial Update --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 40eca1a..e22cf53 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # Rocket.Chat.RealTime.API.Abstraction Abstraction for Utilizing Rocket.Chat's Realtime API Methods with RxJS + +## Installation +``` +npm install --save rocket.chat.realtime.api.rxjs + +``` + +## Usage + +``` + +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.connectToServer(); // Connects to the RealTime API + +realTimeAPI.keepAlive(); // Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive. + +... +... + +// Use any of the methods implmented in the package such as + +login(username, password) //Returns Observable to the Result of the called method, in this case login + +callMethod("method", ...params) // Generic Method to Call any of the method from RealTime API. Returns Observable to the Result of the called method + +callMethod("rooms/get",[{ "$date": Date.now() / 1000 }]); // Returns Observable to the Method called (rooms/get) with params [{ "$date": Date.now() / 1000 }]. + +``` \ No newline at end of file From 115a0b28568df9f3d9bad9d60d79f37f1dd3bac0 Mon Sep 17 00:00:00 2001 From: Viraj Trivedi Date: Thu, 22 Jun 2017 18:36:05 +0530 Subject: [PATCH 2/3] Comments on the Next Line --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e22cf53..51e698a 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,7 @@ Abstraction for Utilizing Rocket.Chat's Realtime API Methods with RxJS ## Installation -``` -npm install --save rocket.chat.realtime.api.rxjs - -``` +` npm install --save rocket.chat.realtime.api.rxjs ` ## Usage @@ -16,19 +13,26 @@ 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.connectToServer(); // Connects to the RealTime API -realTimeAPI.keepAlive(); // Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive. +realTimeAPI.connectToServer(); +// Connects to the RealTime API + + +realTimeAPI.keepAlive(); +// Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive. ... ... // Use any of the methods implmented in the package such as -login(username, password) //Returns Observable to the Result of the called method, in this case login +login(username, password); +//Returns Observable to the Result of the called method, in this case login -callMethod("method", ...params) // Generic Method to Call any of the method from RealTime API. Returns Observable to the Result of the called method +callMethod("method", ...params); +// Generic Method to Call any of the method from RealTime API. Returns Observable to the Result of the called method -callMethod("rooms/get",[{ "$date": Date.now() / 1000 }]); // Returns Observable to the Method called (rooms/get) with params [{ "$date": Date.now() / 1000 }]. +callMethod("rooms/get",[{ "$date": Date.now() / 1000 }]); +// Returns Observable to the Method called (rooms/get) with params [{ "$date": Date.now() / 1000 }]. ``` \ No newline at end of file From d1edf9fdebfad0937a7b33b5f42a1377ac18823f Mon Sep 17 00:00:00 2001 From: Viraj Trivedi Date: Thu, 22 Jun 2017 18:50:55 +0530 Subject: [PATCH 3/3] Methods Described --- README.md | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 51e698a..dc5b460 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ Abstraction for Utilizing Rocket.Chat's Realtime API Methods with RxJS ## Installation -` npm install --save rocket.chat.realtime.api.rxjs ` +``` +npm install --save rocket.chat.realtime.api.rxjs +``` ## Usage @@ -17,22 +19,30 @@ const realTimeAPI = new RealTimeAPI("wss://demo.rocket.chat/websocket"); realTimeAPI.connectToServer(); // Connects to the RealTime API - realTimeAPI.keepAlive(); // Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive. ... ... -// Use any of the methods implmented in the package such as +// Use any of the methods implmented in the package. -login(username, password); -//Returns Observable to the Result of the called method, in this case login - -callMethod("method", ...params); -// Generic Method to Call any of the method from RealTime API. Returns Observable to the Result of the called method - -callMethod("rooms/get",[{ "$date": Date.now() / 1000 }]); -// Returns Observable to the Method called (rooms/get) with params [{ "$date": Date.now() / 1000 }]. +``` -``` \ No newline at end of file +## Methods + +| Methods | Functionality | +|------------------------------------------------------------ |----------------------------------------------------------------------------------------------- | +| connectToServer() | Connects to the RealTime API. | +| keepAlive() | Responds "pong" to the "ping" message sent by the Realtime API. To keep the connection alive. | +| login(username, password) | Returns Observable to the Result/Response from the RealTime API. | +| loginWithAuthToken(authToken) | Returns Observable to the Result/Response from the RealTime API. | +| loginWithOAuth(credToken, credSecret) | Returns Observable to the Result/Response from the RealTime API. | +| callMethod(methodName, ...params) | Returns Observalble to the Result of Method Call from Rocket.Chat Realtime API | +| sendMessage(jsonObject) | Sends the JSON Object to the API Server | +| onMessage( message => console.log(message) ) | Subscribes to the Messages sent from the server | +| onError( error => console.error(error) ) | Subscribes to the Errors. | +| onCompletion( () => console.info("Complete") ) | Subscribes to Completion on the Websocket Connection | +| subscribe(messageHandler, errorHandler, completionHandler) | Subscribes to All 3, messages, errors and completion | +| getObservable() | Returns observable of the WebSocket Connection to the RealTime API | +| | | \ No newline at end of file