@aicore/cocodb-ws-client
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "@aicore/cocodb-ws-client", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Websocket client for cocoDb", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -5,3 +5,3 @@ import {WS} from "./WebSocket.js"; | ||
let client = null; | ||
const WEBSOCKET_ENDPOINT_COCO_DB = '/ws'; | ||
const WEBSOCKET_ENDPOINT_COCO_DB = '/ws/'; | ||
const ID_TO_RESOLVE_REJECT_MAP = {}; | ||
@@ -12,4 +12,10 @@ let id = 0; | ||
/** | ||
* It creates a websocket connection to the cocoDbServiceEndPoint and listens for messages | ||
* @param {string} cocoDbServiceEndPoint - The URL of the coco-db service. | ||
* @param {string} authKey - The authKey is a base64 encoded string of the username and password. | ||
*/ | ||
export function init(cocoDbServiceEndPoint, authKey) { | ||
if (isStringEmpty(cocoDbServiceEndPoint)) { | ||
if (isStringEmpty(cocoDbServiceEndPoint) || !(cocoDbServiceEndPoint.startsWith('ws://') | ||
|| cocoDbServiceEndPoint.startsWith('wss://'))) { | ||
throw new Error('Please provide valid cocoDbServiceEndPoint'); | ||
@@ -20,3 +26,3 @@ } | ||
} | ||
client = new WS.WebSocket(`ws://${cocoDbServiceEndPoint}${WEBSOCKET_ENDPOINT_COCO_DB}`, { | ||
client = new WS.WebSocket(cocoDbServiceEndPoint.trim() + WEBSOCKET_ENDPOINT_COCO_DB, { | ||
perMessageDeflate: false, | ||
@@ -46,2 +52,6 @@ headers: { | ||
/** | ||
* It closes the connection to the server | ||
* @returns The function close() is being returned. | ||
*/ | ||
export function close() { | ||
@@ -54,2 +64,6 @@ if (!client) { | ||
/** | ||
* It returns a string representation of the next integer in a sequence | ||
* @returns {string} A function that increments the id variable and returns the new value as a hexadecimal string. | ||
*/ | ||
function getId() { | ||
@@ -56,0 +70,0 @@ id++; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60563
432