From 7155c4545b7f0d5ec74b7d1e31a6cceec1161844 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 20 Mar 2017 19:22:40 +0300 Subject: [PATCH] Released v5.0.0 --- dist/wampy.js | 2 +- dist/wampy.js.map | 2 +- package.json | 2 +- src/wampy.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/wampy.js b/dist/wampy.js index 26aa1a4..a48d975 100644 --- a/dist/wampy.js +++ b/dist/wampy.js @@ -49,7 +49,7 @@ var Wampy = function () { * @type {string} * @private */ - this.version = 'v4.1.0'; + this.version = 'v5.0.0'; /** * WS Url diff --git a/dist/wampy.js.map b/dist/wampy.js.map index 3e0d399..8ca3d0f 100644 --- a/dist/wampy.js.map +++ b/dist/wampy.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/wampy.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA;;AACA;;AACA;;;;;;;;IAKM,K;;;;;;;;AAOF,mBAAa,GAAb,EAAkB,OAAlB,EAA2B;AAAA;;;;;;;AAOvB,aAAK,OAAL,GAAe,QAAf;;;;;;;AAOA,aAAK,IAAL,GAAa,OAAO,GAAP,KAAe,QAAhB,GAA4B,GAA5B,GAAkC,IAA9C;;;;;;;AAOA,aAAK,UAAL,GAAkB,CAAC,aAAD,CAAlB;;;;;;;AAOA,aAAK,cAAL,GAAsB;AAClB,mBAAO,cAAc,KAAK,OADR;AAElB,mBAAO;AACH,2BAAW;AACP,8BAAU;AACN,uDAA+B,IADzB;AAEN,6CAAqB,IAFf;AAGN,kDAA0B;AAHpB;AADH,iBADR;AAQH,4BAAY,EART;AASH,wBAAQ;AACJ,8BAAU;AACN,+CAAuB,IADjB;AAEN,kDAA0B,IAFpB;AAGN,wCAAgB,IAHV;AAIN,sCAAc;AAJR;AADN,iBATL;AAiBH,wBAAQ;AACJ,8BAAU;AACN,+CAAuB;AADjB;AADN;AAjBL;AAFW,SAAtB;;;;;;;AAgCA,aAAK,M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B;AACH,aAbD,MAaO;;AACH,qBAAK,MAAL,CAAY,QAAZ,GAAuB,0BAAe,mBAAtC;;AAEA,oBAAI,KAAK,cAAL,CAAoB,SAApB,KAAkC,UAAU,OAAhD,EAAyD;AACrD,8BAAU,OAAV,CAAkB,KAAK,MAAL,CAAY,QAAZ,CAAqB,WAAvC;AACH;AAEJ;;AAED,mBAAO,IAAP;AACH;;;;;;kBAGU,K;QACN,K,GAAA,K","file":"wampy.js","sourcesContent":["/**\n * Project: wampy.js\n *\n * https://github.com/KSDaemon/wampy.js\n *\n * A lightweight client-side implementation of\n * WAMP (The WebSocket Application Messaging Protocol v2)\n * http://wamp.ws\n *\n * Provides asynchronous RPC/PubSub over WebSocket.\n *\n * Copyright 2014 KSDaemon. Licensed under the MIT License.\n * See @license text at http://www.opensource.org/licenses/mit-license.php\n *\n */\n\nimport { WAMP_MSG_SPEC, WAMP_ERROR_MSG, isNode } from './constants';\nimport { getWebSocket, isBinaryTypeAllowed } from './utils';\nimport { JsonSerializer } from './serializers/JsonSerializer';\n\n/**\n * WAMP Client Class\n */\nclass Wampy {\n\n /**\n * Wampy constructor\n * @param {string} url\n * @param {Object} options\n */\n constructor (url, options) {\n\n /**\n * Wampy version\n * @type {string}\n * @private\n */\n this.version = 'v4.1.0';\n\n /**\n * WS Url\n * @type {string}\n * @private\n */\n this._url = (typeof url === 'string') ? url : null;\n\n /**\n * WS protocols\n * @type {Array}\n * @private\n */\n this._protocols = ['wamp.2.json'];\n\n /**\n * WAMP features, supported by Wampy\n * @type {object}\n * @private\n */\n this._wamp_features = {\n agent: 'Wampy.js ' + this.version,\n roles: {\n publisher: {\n features: {\n subscriber_blackwhite_listing: true,\n publisher_exclusion: true,\n publisher_identification: true\n }\n },\n subscriber: {},\n caller: {\n features: {\n caller_identification: true,\n progressive_call_results: true,\n call_canceling: true,\n call_timeout: true\n }\n },\n callee: {\n features: {\n caller_identification: true\n }\n }\n }\n };\n\n /**\n * Internal cache for object lifetime\n * @type {Object}\n * @private\n */\n this._cache = {\n /**\n * WAMP Session ID\n * @type {string}\n */\n sessionId: null,\n\n /**\n * Server WAMP roles and features\n */\n server_wamp_features: { roles: {} },\n\n /**\n * Are we in state of saying goodbye\n * @type {boolean}\n */\n isSayingGoodbye: false,\n\n /**\n * Status of last operation\n */\n opStatus: { code: 0, description: 'Success!', reqId: 0 },\n\n /**\n * Timer for reconnection\n * @type {null}\n */\n timer: null,\n\n /**\n * Reconnection attempts\n * @type {number}\n */\n reconnectingAttempts: 0\n };\n\n /**\n * WebSocket object\n * @type {Object}\n * @private\n */\n this._ws = null;\n\n /**\n * Internal queue for websocket requests, for case of disconnect\n * @type {Array}\n * @private\n */\n this._wsQueue = [];\n\n /**\n * Internal queue for wamp requests\n * @type {object}\n * @private\n */\n this._requests = {};\n\n /**\n * Stored RPC\n * @type {object}\n * @private\n */\n this._calls = {};\n\n /**\n * Stored Pub/Sub\n * @type {object}\n * @private\n */\n this._subscriptions = {};\n\n /**\n * Stored Pub/Sub topics\n * @type {Array}\n * @private\n */\n this._subsTopics = new Set();\n\n /**\n * Stored RPC Registrations\n * @type {object}\n * @private\n */\n this._rpcRegs = {};\n\n /**\n * Stored RPC names\n * @type {Array}\n * @private\n */\n this._rpcNames = new Set();\n\n /**\n * Options hash-table\n * @type {Object}\n * @private\n */\n this._options = {\n /**\n * Logging\n * @type {boolean}\n */\n debug: false,\n\n /**\n * Reconnecting flag\n * @type {boolean}\n */\n autoReconnect: true,\n\n /**\n * Reconnecting interval (in ms)\n * @type {number}\n */\n reconnectInterval: 2 * 1000,\n\n /**\n * Maximum reconnection retries\n * @type {number}\n */\n maxRetries: 25,\n\n /**\n * WAMP Realm to join\n * @type {string}\n */\n realm: null,\n\n /**\n * Custom attributes to send to router on hello\n * @type {object}\n */\n helloCustomDetails: null,\n\n /**\n * Authentication id to use in challenge\n * @type {string}\n */\n authid: null,\n\n /**\n * Supported authentication methods\n * @type {array}\n */\n authmethods: [],\n\n /**\n * onChallenge callback\n * @type {function}\n */\n onChallenge: null,\n\n /**\n * onConnect callback\n * @type {function}\n */\n onConnect: null,\n\n /**\n * onClose callback\n * @type {function}\n */\n onClose: null,\n\n /**\n * onError callback\n * @type {function}\n */\n onError: null,\n\n /**\n * onReconnect callback\n * @type {function}\n */\n onReconnect: null,\n\n /**\n * onReconnectSuccess callback\n * @type {function}\n */\n onReconnectSuccess: null,\n\n /**\n * User provided WebSocket class\n * @type {function}\n */\n ws: null,\n\n /**\n * User provided msgpack class\n * @type {object}\n */\n serializer: new JsonSerializer()\n };\n\n if (this._isPlainObject(options)) {\n this._options = this._merge(this._options, options);\n } else if (this._isPlainObject(url)) {\n this._options = this._merge(this._options, url);\n }\n\n this.connect();\n }\n\n /* Internal utils methods */\n /**\n * Internal logger\n * @private\n */\n _log () {\n if (this._options.debug) {\n console.log(arguments);\n }\n }\n\n /**\n * Get the new unique request id\n * @returns {number}\n * @private\n */\n _getReqId () {\n let reqId;\n const max = 2 ^ 53;\n\n do {\n reqId = Math.floor(Math.random() * max);\n } while (reqId in this._requests);\n\n return reqId;\n }\n\n /**\n * Merge argument objects into one\n * @returns {Object}\n * @private\n */\n _merge () {\n const obj = {}, l = arguments.length;\n let i, attr;\n\n for (i = 0; i < l; i++) {\n for (attr in arguments[i]) {\n obj[attr] = arguments[i][attr];\n }\n }\n\n return obj;\n }\n\n /**\n * Check if value is array\n * @param obj\n * @returns {boolean}\n * @private\n */\n _isArray (obj) {\n return (!!obj) && (Array.isArray(obj));\n }\n\n /**\n * Check if value is object literal\n * @param obj\n * @returns {boolean}\n * @private\n */\n _isPlainObject (obj) {\n return (!!obj) && (obj.constructor === Object);\n }\n\n /**\n * Fix websocket protocols based on options\n * @private\n */\n _setWsProtocols () {\n if (!(this._options.serializer instanceof JsonSerializer)) {\n this._protocols.unshift('wamp.2.' + this._options.serializer.protocol);\n }\n }\n\n /**\n * Prerequisite checks for any wampy api call\n * @param {string} topicURI\n * @param {string} role\n * @param {object} callbacks\n * @returns {boolean}\n * @private\n */\n _preReqChecks (topicURI, role, callbacks) {\n let flag = true;\n\n if (this._cache.sessionId && !this._cache.server_wamp_features.roles[role]) {\n this._cache.opStatus = WAMP_ERROR_MSG['NO_' + role.toUpperCase()];\n flag = false;\n }\n\n if (topicURI && !this._validateURI(topicURI)) {\n this._cache.opStatus = WAMP_ERROR_MSG.URI_ERROR;\n flag = false;\n }\n\n if (flag) {\n return true;\n }\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return false;\n }\n\n /**\n * Validate uri\n * @param {string} uri\n * @returns {boolean}\n * @private\n */\n _validateURI (uri) {\n const re = /^([0-9a-zA-Z_]{2,}\\.)*([0-9a-zA-Z_]{2,})$/;\n return !(!re.test(uri) || uri.indexOf('wamp') === 0);\n }\n\n /**\n * Encode WAMP message\n * @param {Array} msg\n * @returns {*}\n * @private\n */\n _encode (msg) {\n try {\n return this._options.serializer.encode(msg);\n } catch (e) {\n throw new Error('[wampy] encoding exception!');\n }\n }\n\n /**\n * Decode WAMP message\n * @param msg\n * @returns {array}\n * @private\n */\n _decode (msg) {\n try {\n return this._options.serializer.decode(msg);\n } catch (e) {\n throw new Error('[wampy] decoding exception!');\n }\n }\n\n /**\n * Send encoded message to server\n * @param {Array} msg\n * @private\n */\n _send (msg) {\n if (msg) {\n this._wsQueue.push(this._encode(msg));\n }\n\n if (this._ws && this._ws.readyState === 1 && this._cache.sessionId) {\n while (this._wsQueue.length) {\n this._ws.send(this._wsQueue.shift());\n }\n }\n }\n\n /**\n * Reset internal state and cache\n * @private\n */\n _resetState () {\n this._wsQueue = [];\n this._subscriptions = {};\n this._subsTopics = new Set();\n this._requests = {};\n this._calls = {};\n this._rpcRegs = {};\n this._rpcNames = new Set();\n\n // Just keep attrs that are have to be present\n this._cache = {\n reconnectingAttempts: 0\n };\n }\n\n /**\n * Initialize internal websocket callbacks\n * @private\n */\n _initWsCallbacks () {\n if (this._ws) {\n this._ws.onopen = () => {\n this._wsOnOpen();\n };\n this._ws.onclose = event => {\n this._wsOnClose(event);\n };\n this._ws.onmessage = event => {\n this._wsOnMessage(event);\n };\n this._ws.onerror = error => {\n this._wsOnError(error);\n };\n }\n }\n\n /**\n * Internal websocket on open callback\n * @private\n */\n _wsOnOpen () {\n const options = this._merge(this._options.helloCustomDetails, this._wamp_features);\n\n if (this._options.authid) {\n options.authmethods = this._options._authmethods;\n options.authid = this._options.authid;\n }\n\n this._log('[wampy] websocket connected');\n\n const type = this._options.serializer.binaryType;\n\n if (!isBinaryTypeAllowed(type)) {\n throw new Error('Binary type is not allowed: ' + type);\n }\n\n this._ws.binatyType = type;\n\n // WAMP SPEC: [HELLO, Realm|uri, Details|dict]\n // Sending directly 'cause it's a hello msg and no sessionId check is needed\n this._ws.send(this._encode([WAMP_MSG_SPEC.HELLO, this._options.realm, options]));\n }\n\n /**\n * Internal websocket on close callback\n * @param {object} event\n * @private\n */\n _wsOnClose (event) {\n const root = isNode ? global : window;\n this._log('[wampy] websocket disconnected. Info: ', event);\n\n // Automatic reconnection\n if ((this._cache.sessionId || this._cache.reconnectingAttempts) &&\n this._options.autoReconnect && this._cache.reconnectingAttempts < this._options.maxRetries && !this._cache.isSayingGoodbye) {\n this._cache.sessionId = null;\n this._cache.timer = root.setTimeout(\n () => {\n this._wsReconnect();\n },\n this._options.reconnectInterval\n );\n } else {\n // No reconnection needed or reached max retries count\n if (this._options.onClose) {\n this._options.onClose();\n }\n\n this._resetState();\n this._ws = null;\n }\n }\n\n /**\n * Internal websocket on event callback\n * @param {object} event\n * @private\n */\n _wsOnMessage (event) {\n let data, id, i, msg, p;\n\n this._log('[wampy] websocket message received', event.data);\n\n data = this._decode(event.data);\n\n switch (data[0]) {\n case WAMP_MSG_SPEC.WELCOME:\n // WAMP SPEC: [WELCOME, Session|id, Details|dict]\n\n this._cache.sessionId = data[1];\n this._cache.server_wamp_features = data[2];\n\n if (this._cache.reconnectingAttempts) {\n // There was reconnection\n\n this._cache.reconnectingAttempts = 0;\n\n if (this._options.onReconnectSuccess) {\n this._options.onReconnectSuccess();\n }\n\n // Let's renew all previous state\n this._renewSubscriptions();\n this._renewRegistrations();\n\n } else {\n // Firing onConnect event on real connection to WAMP server\n if (this._options.onConnect) {\n this._options.onConnect();\n }\n }\n\n // Send local queue if there is something out there\n this._send();\n\n break;\n case WAMP_MSG_SPEC.ABORT:\n // WAMP SPEC: [ABORT, Details|dict, Reason|uri]\n if (this._options.onError) {\n this._options.onError(data[1].message ? data[1].message : data[2]);\n }\n this._ws.close();\n break;\n case WAMP_MSG_SPEC.CHALLENGE:\n // WAMP SPEC: [CHALLENGE, AuthMethod|string, Extra|dict]\n\n if (this._options.authid && typeof this._options.onChallenge === 'function') {\n\n p = new Promise((resolve, reject) => {\n resolve(this._options.onChallenge(data[1], data[2]));\n });\n\n p.then((key) => {\n\n // Sending directly 'cause it's a challenge msg and no sessionId check is needed\n this._ws.send(this._encode([WAMP_MSG_SPEC.AUTHENTICATE, key, {}]));\n\n }).catch(e => {\n this._ws.send(this._encode([\n WAMP_MSG_SPEC.ABORT,\n { message: 'Exception in onChallenge handler raised!' },\n 'wamp.error.cannot_authenticate'\n ]));\n if (this._options.onError) {\n this._options.onError(WAMP_ERROR_MSG.CRA_EXCEPTION.description);\n }\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.CRA_EXCEPTION;\n });\n\n } else {\n\n this._ws.send(this._encode([\n WAMP_MSG_SPEC.ABORT,\n { message: WAMP_ERROR_MSG.NO_CRA_CB_OR_ID.description },\n 'wamp.error.cannot_authenticate'\n ]));\n if (this._options.onError) {\n this._options.onError(WAMP_ERROR_MSG.NO_CRA_CB_OR_ID.description);\n }\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CRA_CB_OR_ID;\n\n }\n break;\n case WAMP_MSG_SPEC.GOODBYE:\n // WAMP SPEC: [GOODBYE, Details|dict, Reason|uri]\n if (!this._cache.isSayingGoodbye) { // get goodbye, initiated by server\n this._cache.isSayingGoodbye = true;\n this._send([WAMP_MSG_SPEC.GOODBYE, {}, 'wamp.error.goodbye_and_out']);\n }\n this._cache.sessionId = null;\n this._ws.close();\n break;\n case WAMP_MSG_SPEC.ERROR:\n // WAMP SPEC: [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict,\n // Error|uri, (Arguments|list, ArgumentsKw|dict)]\n switch (data[1]) {\n case WAMP_MSG_SPEC.SUBSCRIBE:\n case WAMP_MSG_SPEC.UNSUBSCRIBE:\n case WAMP_MSG_SPEC.PUBLISH:\n case WAMP_MSG_SPEC.REGISTER:\n case WAMP_MSG_SPEC.UNREGISTER:\n\n this._requests[data[2]] && this._requests[data[2]].callbacks.onError &&\n this._requests[data[2]].callbacks.onError(data[4], data[3], data[5], data[6]);\n delete this._requests[data[2]];\n\n break;\n case WAMP_MSG_SPEC.INVOCATION:\n break;\n case WAMP_MSG_SPEC.CALL:\n\n // WAMP SPEC: [ERROR, CALL, CALL.Request|id, Details|dict,\n // Error|uri, Arguments|list, ArgumentsKw|dict]\n this._calls[data[2]] && this._calls[data[2]].onError &&\n this._calls[data[2]].onError(data[4], data[3], data[5], data[6]);\n delete this._calls[data[2]];\n\n break;\n default:\n this._log('[wampy] Received non-compliant WAMP ERROR message');\n break;\n }\n break;\n case WAMP_MSG_SPEC.SUBSCRIBED:\n // WAMP SPEC: [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]\n if (this._requests[data[1]]) {\n this._subscriptions[this._requests[data[1]].topic] = this._subscriptions[data[2]] = {\n id: data[2],\n callbacks: [this._requests[data[1]].callbacks.onEvent]\n };\n\n this._subsTopics.add(this._requests[data[1]].topic);\n\n if (this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n case WAMP_MSG_SPEC.UNSUBSCRIBED:\n // WAMP SPEC: [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]\n if (this._requests[data[1]]) {\n id = this._subscriptions[this._requests[data[1]].topic].id;\n delete this._subscriptions[this._requests[data[1]].topic];\n delete this._subscriptions[id];\n\n if (this._subsTopics.has(this._requests[data[1]].topic)) {\n this._subsTopics.delete(this._requests[data[1]].topic);\n }\n\n if (this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n }\n break;\n case WAMP_MSG_SPEC.PUBLISHED:\n // WAMP SPEC: [PUBLISHED, PUBLISH.Request|id, Publication|id]\n if (this._requests[data[1]]) {\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n case WAMP_MSG_SPEC.EVENT:\n if (this._subscriptions[data[1]]) {\n\n // WAMP SPEC: [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id,\n // Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentKw|dict]\n\n i = this._subscriptions[data[1]].callbacks.length;\n while (i--) {\n this._subscriptions[data[1]].callbacks[i](data[4], data[5]);\n }\n\n }\n break;\n case WAMP_MSG_SPEC.RESULT:\n if (this._calls[data[1]]) {\n\n // WAMP SPEC: [RESULT, CALL.Request|id, Details|dict,\n // YIELD.Arguments|list, YIELD.ArgumentsKw|dict]\n\n this._calls[data[1]].onSuccess(data[3], data[4]);\n if (!(data[2].progress && data[2].progress === true)) {\n // We receive final result (progressive or not)\n delete this._calls[data[1]];\n }\n\n }\n break;\n // case WAMP_MSG_SPEC.REGISTER:\n // // WAMP SPEC:\n // break;\n case WAMP_MSG_SPEC.REGISTERED:\n // WAMP SPEC: [REGISTERED, REGISTER.Request|id, Registration|id]\n if (this._requests[data[1]]) {\n this._rpcRegs[this._requests[data[1]].topic] = this._rpcRegs[data[2]] = {\n id: data[2],\n callbacks: [this._requests[data[1]].callbacks.rpc]\n };\n\n this._rpcNames.add(this._requests[data[1]].topic);\n\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n // case WAMP_MSG_SPEC.UNREGISTER:\n // // WAMP SPEC:\n // break;\n case WAMP_MSG_SPEC.UNREGISTERED:\n // WAMP SPEC: [UNREGISTERED, UNREGISTER.Request|id]\n if (this._requests[data[1]]) {\n id = this._rpcRegs[this._requests[data[1]].topic].id;\n delete this._rpcRegs[this._requests[data[1]].topic];\n delete this._rpcRegs[id];\n\n if (this._rpcNames.has(this._requests[data[1]].topic)) {\n this._rpcNames.delete(this._requests[data[1]].topic);\n }\n\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n }\n break;\n case WAMP_MSG_SPEC.INVOCATION:\n if (this._rpcRegs[data[2]]) {\n\n // WAMP SPEC: [INVOCATION, Request|id, REGISTERED.Registration|id,\n // Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict]\n\n p = new Promise((resolve, reject) => {\n resolve(this._rpcRegs[data[2]].callbacks[0](data[4], data[5], data[3]));\n });\n\n p.then((results) => {\n // WAMP SPEC: [YIELD, INVOCATION.Request|id, Options|dict, (Arguments|list, ArgumentsKw|dict)]\n msg = [WAMP_MSG_SPEC.YIELD, data[1], {}];\n if (this._isArray(results)) {\n // Options\n if (this._isPlainObject(results[0])) {\n msg[2] = results[0];\n }\n\n if (this._isArray(results[1])) {\n msg.push(results[1]);\n } else if (typeof (results[1]) !== 'undefined') {\n msg.push([results[1]]);\n }\n\n if (this._isPlainObject(results[2])) {\n if (msg.length === 3) {\n msg.push([]);\n }\n msg.push(results[2]);\n }\n } else {\n msg = [WAMP_MSG_SPEC.YIELD, data[1], {}];\n }\n this._send(msg);\n\n }).catch(e => {\n let msg = [WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.INVOCATION,\n data[1], e.details || {}, e.uri || 'wamp.error.invocation_exception'];\n\n if (e.argsList && this._isArray(e.argsList)) {\n msg.push(e.argsList);\n }\n\n if (e.argsDict && this._isPlainObject(e.argsDict)) {\n if (msg.length === 5) {\n msg.push([]);\n }\n msg.push(e.argsDict);\n }\n this._send(msg);\n });\n\n } else {\n // WAMP SPEC: [ERROR, INVOCATION, INVOCATION.Request|id, Details|dict, Error|uri]\n this._send([WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.INVOCATION,\n data[1], {}, 'wamp.error.no_such_procedure']);\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_INVOCATION;\n }\n\n break;\n // case WAMP_MSG_SPEC.INTERRUPT:\n // // WAMP SPEC:\n // break;\n // case WAMP_MSG_SPEC.YIELD:\n // // WAMP SPEC:\n // break;\n default:\n this._log('[wampy] Received non-compliant WAMP message');\n break;\n }\n }\n\n /**\n * Internal websocket on error callback\n * @param {object} error\n * @private\n */\n _wsOnError (error) {\n this._log('[wampy] websocket error');\n\n if (this._options.onError) {\n this._options.onError(error);\n }\n }\n\n /**\n * Reconnect to server in case of websocket error\n * @private\n */\n _wsReconnect () {\n this._log('[wampy] websocket reconnecting...');\n\n if (this._options.onReconnect) {\n this._options.onReconnect();\n }\n\n this._cache.reconnectingAttempts++;\n this._ws = getWebSocket(this._url, this._protocols, this._options.ws);\n this._initWsCallbacks();\n }\n\n /**\n * Resubscribe to topics in case of communication error\n * @private\n */\n _renewSubscriptions () {\n let i;\n const subs = this._subscriptions,\n st = this._subsTopics;\n\n this._subscriptions = {};\n this._subsTopics = new Set();\n\n for (let topic of st) {\n i = subs[topic].callbacks.length;\n while (i--) {\n this.subscribe(topic, subs[topic].callbacks[i]);\n }\n }\n }\n\n /**\n * Reregister RPCs in case of communication error\n * @private\n */\n _renewRegistrations () {\n const rpcs = this._rpcRegs,\n rn = this._rpcNames;\n\n this._rpcRegs = {};\n this._rpcNames = new Set();\n\n for (let rpcName of rn) {\n this.register(rpcName, { rpc: rpcs[rpcName].callbacks[0] });\n }\n }\n\n /* Wampy public API */\n\n /**\n * Get or set Wampy options\n *\n * To get options - call without parameters\n * To set options - pass hash-table with options values\n *\n * @param {object} opts\n * @returns {*}\n */\n options (opts) {\n if (typeof (opts) === 'undefined') {\n return this._options;\n } else if (this._isPlainObject(opts)) {\n this._options = this._merge(this._options, opts);\n return this;\n }\n }\n\n /**\n * Get the status of last operation\n *\n * @returns {object} with 2 fields: code, description\n * code: 0 - if operation was successful\n * code > 0 - if error occurred\n * description contains details about error\n * reqId: last send request ID\n */\n getOpStatus () {\n return this._cache.opStatus;\n }\n\n /**\n * Get the WAMP Session ID\n *\n * @returns {string} Session ID\n */\n getSessionId () {\n return this._cache.sessionId;\n }\n\n /**\n * Connect to server\n * @param {string} url New url (optional)\n * @returns {Wampy}\n */\n connect (url) {\n if (url) {\n this._url = url;\n }\n\n if (this._options.realm) {\n\n const authp = (this._options.authid ? 1 : 0) +\n ((this._isArray(this._options.authmethods) && this._options.authmethods.length) ? 1 : 0) +\n (typeof this._options.onChallenge === 'function' ? 1 : 0);\n\n if (authp > 0 && authp < 3) {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CRA_CB_OR_ID;\n return this;\n }\n\n this._setWsProtocols();\n this._ws = getWebSocket(this._url, this._protocols, this._options.ws);\n if (!this._ws) {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_WS_OR_URL;\n return this;\n }\n this._initWsCallbacks();\n\n } else {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_REALM;\n }\n\n return this;\n }\n\n /**\n * Disconnect from server\n * @returns {Wampy}\n */\n disconnect () {\n if (this._cache.sessionId) {\n // need to send goodbye message to server\n this._cache.isSayingGoodbye = true;\n this._send([WAMP_MSG_SPEC.GOODBYE, {}, 'wamp.error.system_shutdown']);\n } else if (this._ws) {\n this._ws.close();\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n\n return this;\n }\n\n /**\n * Abort WAMP session establishment\n *\n * @returns {Wampy}\n */\n abort () {\n\n if (!this._cache.sessionId && this._ws.readyState === 1) {\n this._send([WAMP_MSG_SPEC.ABORT, {}, 'wamp.error.abort']);\n this._cache.sessionId = null;\n }\n\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n\n return this;\n }\n\n /**\n * Subscribe to a topic on a broker\n *\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as published event callback\n * or it can be hash table of callbacks:\n * { onSuccess: will be called when subscribe would be confirmed\n * onError: will be called if subscribe would be aborted\n * onEvent: will be called on receiving published event }\n *\n * @returns {Wampy}\n */\n subscribe (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'broker', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onEvent: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onEvent) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (!this._subscriptions[topicURI] || !this._subscriptions[topicURI].callbacks.length) {\n // no such subscription or processing unsubscribing\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]\n this._send([WAMP_MSG_SPEC.SUBSCRIBE, reqId, {}, topicURI]);\n\n } else { // already have subscription to this topic\n // There is no such callback yet\n if (this._subscriptions[topicURI].callbacks.indexOf(callbacks.onEvent) < 0) {\n this._subscriptions[topicURI].callbacks.push(callbacks.onEvent);\n }\n\n if (callbacks.onSuccess) {\n callbacks.onSuccess();\n }\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Unsubscribe from topic\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as\n * published event callback to remove or it can be hash table of callbacks:\n * { onSuccess: will be called when unsubscribe would be confirmed\n * onError: will be called if unsubscribe would be aborted\n * onEvent: published event callback to remove }\n * @returns {Wampy}\n */\n unsubscribe (topicURI, callbacks) {\n let reqId, i = -1;\n\n if (!this._preReqChecks(null, 'broker', callbacks)) {\n return this;\n }\n\n if (this._subscriptions[topicURI]) {\n\n reqId = this._getReqId();\n\n if (typeof (callbacks) === 'undefined') {\n this._subscriptions[topicURI].callbacks = [];\n callbacks = {};\n } else if (typeof callbacks === 'function') {\n i = this._subscriptions[topicURI].callbacks.indexOf(callbacks);\n callbacks = {};\n } else if (callbacks.onEvent && typeof callbacks.onEvent === 'function') {\n i = this._subscriptions[topicURI].callbacks.indexOf(callbacks.onEvent);\n } else {\n this._subscriptions[topicURI].callbacks = [];\n }\n\n if (i >= 0) {\n this._subscriptions[topicURI].callbacks.splice(i, 1);\n }\n\n if (this._subscriptions[topicURI].callbacks.length) {\n // There are another callbacks for this topic\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n return this;\n }\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP_SPEC: [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]\n this._send([WAMP_MSG_SPEC.UNSUBSCRIBE, reqId, this._subscriptions[topicURI].id]);\n\n } else {\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_UNSUBSCRIBE;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Publish a event to topic\n * @param {string} topicURI\n * @param {string|number|Array|object} payload - optional parameter.\n * @param {object} callbacks - optional hash table of callbacks:\n * { onSuccess: will be called when publishing would be confirmed\n * onError: will be called if publishing would be aborted }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { exclude: integer|array WAMP session id(s) that won't receive a published event,\n * even though they may be subscribed\n * exclude_authid: string|array Authentication id(s) that won't receive\n * a published event, even though they may be subscribed\n * exclude_authrole: string|array Authentication role(s) that won't receive\n * a published event, even though they may be subscribed\n * eligible: integer|array WAMP session id(s) that are allowed\n * to receive a published event\n * eligible_authid: string|array Authentication id(s) that are allowed\n * to receive a published event\n * eligible_authrole: string|array Authentication role(s) that are allowed\n * to receive a published event\n * exclude_me: bool flag of receiving publishing event by initiator\n * disclose_me: bool flag of disclosure of publisher identity (its WAMP session ID)\n * to receivers of a published event }\n * @returns {Wampy}\n */\n publish (topicURI, payload, callbacks, advancedOptions) {\n let reqId, msg, err = false;\n const options = {};\n\n if (!this._preReqChecks(topicURI, 'broker', callbacks)) {\n return this;\n }\n\n if (this._isPlainObject(callbacks)) {\n options.acknowledge = true;\n }\n\n if (typeof (advancedOptions) !== 'undefined') {\n\n if (this._isPlainObject(advancedOptions)) {\n if (advancedOptions.exclude) {\n if (this._isArray(advancedOptions.exclude) && advancedOptions.exclude.length) {\n options.exclude = advancedOptions.exclude;\n } else if (typeof advancedOptions.exclude === 'number') {\n options.exclude = [advancedOptions.exclude];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.exclude_authid) {\n if (this._isArray(advancedOptions.exclude_authid) && advancedOptions.exclude_authid.length) {\n options.exclude_authid = advancedOptions.exclude_authid;\n } else if (typeof advancedOptions.exclude_authid === 'string') {\n options.exclude_authid = [advancedOptions.exclude_authid];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.exclude_authrole) {\n if (this._isArray(advancedOptions.exclude_authrole) && advancedOptions.exclude_authrole.length) {\n options.exclude_authrole = advancedOptions.exclude_authrole;\n } else if (typeof advancedOptions.exclude_authrole === 'string') {\n options.exclude_authrole = [advancedOptions.exclude_authrole];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible) {\n if (this._isArray(advancedOptions.eligible) && advancedOptions.eligible.length) {\n options.eligible = advancedOptions.eligible;\n } else if (typeof advancedOptions.eligible === 'number') {\n options.eligible = [advancedOptions.eligible];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible_authid) {\n if (this._isArray(advancedOptions.eligible_authid) && advancedOptions.eligible_authid.length) {\n options.eligible_authid = advancedOptions.eligible_authid;\n } else if (typeof advancedOptions.eligible_authid === 'string') {\n options.eligible_authid = [advancedOptions.eligible_authid];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible_authrole) {\n if (this._isArray(advancedOptions.eligible_authrole) && advancedOptions.eligible_authrole.length) {\n options.eligible_authrole = advancedOptions.eligible_authrole;\n } else if (typeof advancedOptions.eligible_authrole === 'string') {\n options.eligible_authrole = [advancedOptions.eligible_authrole];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.hasOwnProperty('exclude_me')) {\n options.exclude_me = advancedOptions.exclude_me !== false;\n }\n\n if (advancedOptions.hasOwnProperty('disclose_me')) {\n options.disclose_me = advancedOptions.disclose_me === true;\n }\n\n } else {\n err = true;\n }\n\n if (err) {\n this._cache.opStatus = WAMP_ERROR_MSG.INVALID_PARAM;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n }\n\n reqId = this._getReqId();\n\n switch (arguments.length) {\n case 1:\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri]\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI];\n break;\n case 2:\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list (, ArgumentsKw|dict)]\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [payload]];\n }\n break;\n default:\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list (, ArgumentsKw|dict)]\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [payload]];\n }\n break;\n }\n\n this._send(msg);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Remote Procedure Call\n * @param {string} topicURI\n * @param {string|number|Array|object} payload - can be either a value of any type or null\n * @param {function|object} callbacks - if it is a function - it will be treated as result callback function\n * or it can be hash table of callbacks:\n * { onSuccess: will be called with result on successful call\n * onError: will be called if invocation would be aborted }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { disclose_me: bool flag of disclosure of Caller identity (WAMP session ID)\n * to endpoints of a routed call\n * receive_progress: bool flag for receiving progressive results. In this case\n * onSuccess function will be called every time on receiving result\n * timeout: integer timeout (in ms) for the call to finish }\n * @returns {Wampy}\n */\n call (topicURI, payload, callbacks, advancedOptions) {\n let reqId, msg, err = false;\n const options = {};\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onSuccess: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onSuccess) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (typeof (advancedOptions) !== 'undefined') {\n\n if (this._isPlainObject(advancedOptions)) {\n if (advancedOptions.hasOwnProperty('disclose_me')) {\n options.disclose_me = advancedOptions.disclose_me === true;\n }\n\n if (advancedOptions.hasOwnProperty('receive_progress')) {\n options.receive_progress = advancedOptions.receive_progress === true;\n }\n\n if (advancedOptions.hasOwnProperty('timeout')) {\n if (typeof advancedOptions.timeout === 'number') {\n options.timeout = advancedOptions.timeout;\n } else {\n err = true;\n }\n }\n\n } else {\n err = true;\n }\n\n if (err) {\n this._cache.opStatus = WAMP_ERROR_MSG.INVALID_PARAM;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n }\n\n do {\n reqId = this._getReqId();\n } while (reqId in this._calls);\n\n this._calls[reqId] = callbacks;\n\n // WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri, (Arguments|list, ArgumentsKw|dict)]\n if (payload === null) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI];\n } else {\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, [payload]];\n }\n }\n\n this._send(msg);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * RPC invocation cancelling\n *\n * @param {int} reqId RPC call request ID\n * @param {function|object} callbacks - if it is a function - it will be called if successfully\n * sent canceling message or it can be hash table of callbacks:\n * { onSuccess: will be called if successfully sent canceling message\n * onError: will be called if some error occurred }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { mode: string|one of the possible modes:\n * \"skip\" | \"kill\" | \"killnowait\". Skip is default.\n * }\n *\n * @returns {Wampy}\n */\n cancel (reqId, callbacks, advancedOptions) {\n const options = { mode: 'skip' };\n\n if (!this._preReqChecks(null, 'dealer', callbacks)) {\n return this;\n }\n\n if (!reqId || !this._calls[reqId]) {\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_REQ_ID;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if ((typeof (advancedOptions) !== 'undefined') &&\n (this._isPlainObject(advancedOptions)) &&\n (advancedOptions.hasOwnProperty('mode'))) {\n\n options.mode = /skip|kill|killnowait/.test(advancedOptions.mode) ? advancedOptions.mode : 'skip';\n }\n\n // WAMP SPEC: [CANCEL, CALL.Request|id, Options|dict]\n this._send([WAMP_MSG_SPEC.CANCEL, reqId, options]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n\n callbacks.onSuccess && callbacks.onSuccess();\n\n return this;\n }\n\n /**\n * RPC registration for invocation\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as rpc itself\n * or it can be hash table of callbacks:\n * { rpc: registered procedure\n * onSuccess: will be called on successful registration\n * onError: will be called if registration would be aborted }\n * @returns {Wampy}\n */\n register (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { rpc: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.rpc) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (!this._rpcRegs[topicURI] || !this._rpcRegs[topicURI].callbacks.length) {\n // no such registration or processing unregistering\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [REGISTER, Request|id, Options|dict, Procedure|uri]\n this._send([WAMP_MSG_SPEC.REGISTER, reqId, {}, topicURI]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n } else { // already have registration with such topicURI\n this._cache.opStatus = WAMP_ERROR_MSG.RPC_ALREADY_REGISTERED;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n }\n\n return this;\n\n }\n\n /**\n * RPC unregistration for invocation\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function, it will be called on successful unregistration\n * or it can be hash table of callbacks:\n * { onSuccess: will be called on successful unregistration\n * onError: will be called if unregistration would be aborted }\n * @returns {Wampy}\n */\n unregister (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onSuccess: callbacks };\n }\n\n if (this._rpcRegs[topicURI]) { // there is such registration\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [UNREGISTER, Request|id, REGISTERED.Registration|id]\n this._send([WAMP_MSG_SPEC.UNREGISTER, reqId, this._rpcRegs[topicURI].id]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n } else { // there is no registration with such topicURI\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_UNREG;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n }\n\n return this;\n }\n}\n\nexport default Wampy;\nexport { Wampy };\n"]} \ No newline at end of file +{"version":3,"sources":["../src/wampy.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA;;AACA;;AACA;;;;;;;;IAKM,K;;;;;;;;AAOF,mBAAa,GAAb,EAAkB,OAAlB,EAA2B;AAAA;;;;;;;AAOvB,aAAK,OAAL,GAAe,QAAf;;;;;;;AAOA,aAAK,IAAL,GAAa,OAAO,GAAP,KAAe,QAAhB,GAA4B,GAA5B,GAAkC,IAA9C;;;;;;;AAOA,aAAK,UAAL,GAAkB,CAAC,aAAD,CAAlB;;;;;;;AAOA,aAAK,cAAL,GA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L,CAAc,QAAd,CAAJ,EAA6B;;;AAEzB,wBAAQ,KAAK,SAAL,EAAR;;AAEA,qBAAK,SAAL,CAAe,KAAf,IAAwB;AACpB,2BAAO,QADa;AAEpB,+BAAW;AAFS,iBAAxB;;;AAMA,qBAAK,KAAL,CAAW,CAAC,yBAAc,UAAf,EAA2B,KAA3B,EAAkC,KAAK,QAAL,CAAc,QAAd,EAAwB,EAA1D,CAAX;AACA,qBAAK,MAAL,CAAY,QAAZ,GAAuB,0BAAe,OAAtC;AACA,qBAAK,MAAL,CAAY,QAAZ,CAAqB,KAArB,GAA6B,KAA7B;AACH,aAbD,MAaO;;AACH,qBAAK,MAAL,CAAY,QAAZ,GAAuB,0BAAe,mBAAtC;;AAEA,oBAAI,KAAK,cAAL,CAAoB,SAApB,KAAkC,UAAU,OAAhD,EAAyD;AACrD,8BAAU,OAAV,CAAkB,KAAK,MAAL,CAAY,QAAZ,CAAqB,WAAvC;AACH;AAEJ;;AAED,mBAAO,IAAP;AACH;;;;;;kBAGU,K;QACN,K,GAAA,K","file":"wampy.js","sourcesContent":["/**\n * Project: wampy.js\n *\n * https://github.com/KSDaemon/wampy.js\n *\n * A lightweight client-side implementation of\n * WAMP (The WebSocket Application Messaging Protocol v2)\n * http://wamp.ws\n *\n * Provides asynchronous RPC/PubSub over WebSocket.\n *\n * Copyright 2014 KSDaemon. Licensed under the MIT License.\n * See @license text at http://www.opensource.org/licenses/mit-license.php\n *\n */\n\nimport { WAMP_MSG_SPEC, WAMP_ERROR_MSG, isNode } from './constants';\nimport { getWebSocket, isBinaryTypeAllowed } from './utils';\nimport { JsonSerializer } from './serializers/JsonSerializer';\n\n/**\n * WAMP Client Class\n */\nclass Wampy {\n\n /**\n * Wampy constructor\n * @param {string} url\n * @param {Object} options\n */\n constructor (url, options) {\n\n /**\n * Wampy version\n * @type {string}\n * @private\n */\n this.version = 'v5.0.0';\n\n /**\n * WS Url\n * @type {string}\n * @private\n */\n this._url = (typeof url === 'string') ? url : null;\n\n /**\n * WS protocols\n * @type {Array}\n * @private\n */\n this._protocols = ['wamp.2.json'];\n\n /**\n * WAMP features, supported by Wampy\n * @type {object}\n * @private\n */\n this._wamp_features = {\n agent: 'Wampy.js ' + this.version,\n roles: {\n publisher: {\n features: {\n subscriber_blackwhite_listing: true,\n publisher_exclusion: true,\n publisher_identification: true\n }\n },\n subscriber: {},\n caller: {\n features: {\n caller_identification: true,\n progressive_call_results: true,\n call_canceling: true,\n call_timeout: true\n }\n },\n callee: {\n features: {\n caller_identification: true\n }\n }\n }\n };\n\n /**\n * Internal cache for object lifetime\n * @type {Object}\n * @private\n */\n this._cache = {\n /**\n * WAMP Session ID\n * @type {string}\n */\n sessionId: null,\n\n /**\n * Server WAMP roles and features\n */\n server_wamp_features: { roles: {} },\n\n /**\n * Are we in state of saying goodbye\n * @type {boolean}\n */\n isSayingGoodbye: false,\n\n /**\n * Status of last operation\n */\n opStatus: { code: 0, description: 'Success!', reqId: 0 },\n\n /**\n * Timer for reconnection\n * @type {null}\n */\n timer: null,\n\n /**\n * Reconnection attempts\n * @type {number}\n */\n reconnectingAttempts: 0\n };\n\n /**\n * WebSocket object\n * @type {Object}\n * @private\n */\n this._ws = null;\n\n /**\n * Internal queue for websocket requests, for case of disconnect\n * @type {Array}\n * @private\n */\n this._wsQueue = [];\n\n /**\n * Internal queue for wamp requests\n * @type {object}\n * @private\n */\n this._requests = {};\n\n /**\n * Stored RPC\n * @type {object}\n * @private\n */\n this._calls = {};\n\n /**\n * Stored Pub/Sub\n * @type {object}\n * @private\n */\n this._subscriptions = {};\n\n /**\n * Stored Pub/Sub topics\n * @type {Array}\n * @private\n */\n this._subsTopics = new Set();\n\n /**\n * Stored RPC Registrations\n * @type {object}\n * @private\n */\n this._rpcRegs = {};\n\n /**\n * Stored RPC names\n * @type {Array}\n * @private\n */\n this._rpcNames = new Set();\n\n /**\n * Options hash-table\n * @type {Object}\n * @private\n */\n this._options = {\n /**\n * Logging\n * @type {boolean}\n */\n debug: false,\n\n /**\n * Reconnecting flag\n * @type {boolean}\n */\n autoReconnect: true,\n\n /**\n * Reconnecting interval (in ms)\n * @type {number}\n */\n reconnectInterval: 2 * 1000,\n\n /**\n * Maximum reconnection retries\n * @type {number}\n */\n maxRetries: 25,\n\n /**\n * WAMP Realm to join\n * @type {string}\n */\n realm: null,\n\n /**\n * Custom attributes to send to router on hello\n * @type {object}\n */\n helloCustomDetails: null,\n\n /**\n * Authentication id to use in challenge\n * @type {string}\n */\n authid: null,\n\n /**\n * Supported authentication methods\n * @type {array}\n */\n authmethods: [],\n\n /**\n * onChallenge callback\n * @type {function}\n */\n onChallenge: null,\n\n /**\n * onConnect callback\n * @type {function}\n */\n onConnect: null,\n\n /**\n * onClose callback\n * @type {function}\n */\n onClose: null,\n\n /**\n * onError callback\n * @type {function}\n */\n onError: null,\n\n /**\n * onReconnect callback\n * @type {function}\n */\n onReconnect: null,\n\n /**\n * onReconnectSuccess callback\n * @type {function}\n */\n onReconnectSuccess: null,\n\n /**\n * User provided WebSocket class\n * @type {function}\n */\n ws: null,\n\n /**\n * User provided msgpack class\n * @type {object}\n */\n serializer: new JsonSerializer()\n };\n\n if (this._isPlainObject(options)) {\n this._options = this._merge(this._options, options);\n } else if (this._isPlainObject(url)) {\n this._options = this._merge(this._options, url);\n }\n\n this.connect();\n }\n\n /* Internal utils methods */\n /**\n * Internal logger\n * @private\n */\n _log () {\n if (this._options.debug) {\n console.log(arguments);\n }\n }\n\n /**\n * Get the new unique request id\n * @returns {number}\n * @private\n */\n _getReqId () {\n let reqId;\n const max = 2 ^ 53;\n\n do {\n reqId = Math.floor(Math.random() * max);\n } while (reqId in this._requests);\n\n return reqId;\n }\n\n /**\n * Merge argument objects into one\n * @returns {Object}\n * @private\n */\n _merge () {\n const obj = {}, l = arguments.length;\n let i, attr;\n\n for (i = 0; i < l; i++) {\n for (attr in arguments[i]) {\n obj[attr] = arguments[i][attr];\n }\n }\n\n return obj;\n }\n\n /**\n * Check if value is array\n * @param obj\n * @returns {boolean}\n * @private\n */\n _isArray (obj) {\n return (!!obj) && (Array.isArray(obj));\n }\n\n /**\n * Check if value is object literal\n * @param obj\n * @returns {boolean}\n * @private\n */\n _isPlainObject (obj) {\n return (!!obj) && (obj.constructor === Object);\n }\n\n /**\n * Fix websocket protocols based on options\n * @private\n */\n _setWsProtocols () {\n if (!(this._options.serializer instanceof JsonSerializer)) {\n this._protocols.unshift('wamp.2.' + this._options.serializer.protocol);\n }\n }\n\n /**\n * Prerequisite checks for any wampy api call\n * @param {string} topicURI\n * @param {string} role\n * @param {object} callbacks\n * @returns {boolean}\n * @private\n */\n _preReqChecks (topicURI, role, callbacks) {\n let flag = true;\n\n if (this._cache.sessionId && !this._cache.server_wamp_features.roles[role]) {\n this._cache.opStatus = WAMP_ERROR_MSG['NO_' + role.toUpperCase()];\n flag = false;\n }\n\n if (topicURI && !this._validateURI(topicURI)) {\n this._cache.opStatus = WAMP_ERROR_MSG.URI_ERROR;\n flag = false;\n }\n\n if (flag) {\n return true;\n }\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return false;\n }\n\n /**\n * Validate uri\n * @param {string} uri\n * @returns {boolean}\n * @private\n */\n _validateURI (uri) {\n const re = /^([0-9a-zA-Z_]{2,}\\.)*([0-9a-zA-Z_]{2,})$/;\n return !(!re.test(uri) || uri.indexOf('wamp') === 0);\n }\n\n /**\n * Encode WAMP message\n * @param {Array} msg\n * @returns {*}\n * @private\n */\n _encode (msg) {\n try {\n return this._options.serializer.encode(msg);\n } catch (e) {\n throw new Error('[wampy] encoding exception!');\n }\n }\n\n /**\n * Decode WAMP message\n * @param msg\n * @returns {array}\n * @private\n */\n _decode (msg) {\n try {\n return this._options.serializer.decode(msg);\n } catch (e) {\n throw new Error('[wampy] decoding exception!');\n }\n }\n\n /**\n * Send encoded message to server\n * @param {Array} msg\n * @private\n */\n _send (msg) {\n if (msg) {\n this._wsQueue.push(this._encode(msg));\n }\n\n if (this._ws && this._ws.readyState === 1 && this._cache.sessionId) {\n while (this._wsQueue.length) {\n this._ws.send(this._wsQueue.shift());\n }\n }\n }\n\n /**\n * Reset internal state and cache\n * @private\n */\n _resetState () {\n this._wsQueue = [];\n this._subscriptions = {};\n this._subsTopics = new Set();\n this._requests = {};\n this._calls = {};\n this._rpcRegs = {};\n this._rpcNames = new Set();\n\n // Just keep attrs that are have to be present\n this._cache = {\n reconnectingAttempts: 0\n };\n }\n\n /**\n * Initialize internal websocket callbacks\n * @private\n */\n _initWsCallbacks () {\n if (this._ws) {\n this._ws.onopen = () => {\n this._wsOnOpen();\n };\n this._ws.onclose = event => {\n this._wsOnClose(event);\n };\n this._ws.onmessage = event => {\n this._wsOnMessage(event);\n };\n this._ws.onerror = error => {\n this._wsOnError(error);\n };\n }\n }\n\n /**\n * Internal websocket on open callback\n * @private\n */\n _wsOnOpen () {\n const options = this._merge(this._options.helloCustomDetails, this._wamp_features);\n\n if (this._options.authid) {\n options.authmethods = this._options._authmethods;\n options.authid = this._options.authid;\n }\n\n this._log('[wampy] websocket connected');\n\n const type = this._options.serializer.binaryType;\n\n if (!isBinaryTypeAllowed(type)) {\n throw new Error('Binary type is not allowed: ' + type);\n }\n\n this._ws.binatyType = type;\n\n // WAMP SPEC: [HELLO, Realm|uri, Details|dict]\n // Sending directly 'cause it's a hello msg and no sessionId check is needed\n this._ws.send(this._encode([WAMP_MSG_SPEC.HELLO, this._options.realm, options]));\n }\n\n /**\n * Internal websocket on close callback\n * @param {object} event\n * @private\n */\n _wsOnClose (event) {\n const root = isNode ? global : window;\n this._log('[wampy] websocket disconnected. Info: ', event);\n\n // Automatic reconnection\n if ((this._cache.sessionId || this._cache.reconnectingAttempts) &&\n this._options.autoReconnect && this._cache.reconnectingAttempts < this._options.maxRetries && !this._cache.isSayingGoodbye) {\n this._cache.sessionId = null;\n this._cache.timer = root.setTimeout(\n () => {\n this._wsReconnect();\n },\n this._options.reconnectInterval\n );\n } else {\n // No reconnection needed or reached max retries count\n if (this._options.onClose) {\n this._options.onClose();\n }\n\n this._resetState();\n this._ws = null;\n }\n }\n\n /**\n * Internal websocket on event callback\n * @param {object} event\n * @private\n */\n _wsOnMessage (event) {\n let data, id, i, msg, p;\n\n this._log('[wampy] websocket message received', event.data);\n\n data = this._decode(event.data);\n\n switch (data[0]) {\n case WAMP_MSG_SPEC.WELCOME:\n // WAMP SPEC: [WELCOME, Session|id, Details|dict]\n\n this._cache.sessionId = data[1];\n this._cache.server_wamp_features = data[2];\n\n if (this._cache.reconnectingAttempts) {\n // There was reconnection\n\n this._cache.reconnectingAttempts = 0;\n\n if (this._options.onReconnectSuccess) {\n this._options.onReconnectSuccess();\n }\n\n // Let's renew all previous state\n this._renewSubscriptions();\n this._renewRegistrations();\n\n } else {\n // Firing onConnect event on real connection to WAMP server\n if (this._options.onConnect) {\n this._options.onConnect();\n }\n }\n\n // Send local queue if there is something out there\n this._send();\n\n break;\n case WAMP_MSG_SPEC.ABORT:\n // WAMP SPEC: [ABORT, Details|dict, Reason|uri]\n if (this._options.onError) {\n this._options.onError(data[1].message ? data[1].message : data[2]);\n }\n this._ws.close();\n break;\n case WAMP_MSG_SPEC.CHALLENGE:\n // WAMP SPEC: [CHALLENGE, AuthMethod|string, Extra|dict]\n\n if (this._options.authid && typeof this._options.onChallenge === 'function') {\n\n p = new Promise((resolve, reject) => {\n resolve(this._options.onChallenge(data[1], data[2]));\n });\n\n p.then((key) => {\n\n // Sending directly 'cause it's a challenge msg and no sessionId check is needed\n this._ws.send(this._encode([WAMP_MSG_SPEC.AUTHENTICATE, key, {}]));\n\n }).catch(e => {\n this._ws.send(this._encode([\n WAMP_MSG_SPEC.ABORT,\n { message: 'Exception in onChallenge handler raised!' },\n 'wamp.error.cannot_authenticate'\n ]));\n if (this._options.onError) {\n this._options.onError(WAMP_ERROR_MSG.CRA_EXCEPTION.description);\n }\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.CRA_EXCEPTION;\n });\n\n } else {\n\n this._ws.send(this._encode([\n WAMP_MSG_SPEC.ABORT,\n { message: WAMP_ERROR_MSG.NO_CRA_CB_OR_ID.description },\n 'wamp.error.cannot_authenticate'\n ]));\n if (this._options.onError) {\n this._options.onError(WAMP_ERROR_MSG.NO_CRA_CB_OR_ID.description);\n }\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CRA_CB_OR_ID;\n\n }\n break;\n case WAMP_MSG_SPEC.GOODBYE:\n // WAMP SPEC: [GOODBYE, Details|dict, Reason|uri]\n if (!this._cache.isSayingGoodbye) { // get goodbye, initiated by server\n this._cache.isSayingGoodbye = true;\n this._send([WAMP_MSG_SPEC.GOODBYE, {}, 'wamp.error.goodbye_and_out']);\n }\n this._cache.sessionId = null;\n this._ws.close();\n break;\n case WAMP_MSG_SPEC.ERROR:\n // WAMP SPEC: [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict,\n // Error|uri, (Arguments|list, ArgumentsKw|dict)]\n switch (data[1]) {\n case WAMP_MSG_SPEC.SUBSCRIBE:\n case WAMP_MSG_SPEC.UNSUBSCRIBE:\n case WAMP_MSG_SPEC.PUBLISH:\n case WAMP_MSG_SPEC.REGISTER:\n case WAMP_MSG_SPEC.UNREGISTER:\n\n this._requests[data[2]] && this._requests[data[2]].callbacks.onError &&\n this._requests[data[2]].callbacks.onError(data[4], data[3], data[5], data[6]);\n delete this._requests[data[2]];\n\n break;\n case WAMP_MSG_SPEC.INVOCATION:\n break;\n case WAMP_MSG_SPEC.CALL:\n\n // WAMP SPEC: [ERROR, CALL, CALL.Request|id, Details|dict,\n // Error|uri, Arguments|list, ArgumentsKw|dict]\n this._calls[data[2]] && this._calls[data[2]].onError &&\n this._calls[data[2]].onError(data[4], data[3], data[5], data[6]);\n delete this._calls[data[2]];\n\n break;\n default:\n this._log('[wampy] Received non-compliant WAMP ERROR message');\n break;\n }\n break;\n case WAMP_MSG_SPEC.SUBSCRIBED:\n // WAMP SPEC: [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]\n if (this._requests[data[1]]) {\n this._subscriptions[this._requests[data[1]].topic] = this._subscriptions[data[2]] = {\n id: data[2],\n callbacks: [this._requests[data[1]].callbacks.onEvent]\n };\n\n this._subsTopics.add(this._requests[data[1]].topic);\n\n if (this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n case WAMP_MSG_SPEC.UNSUBSCRIBED:\n // WAMP SPEC: [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]\n if (this._requests[data[1]]) {\n id = this._subscriptions[this._requests[data[1]].topic].id;\n delete this._subscriptions[this._requests[data[1]].topic];\n delete this._subscriptions[id];\n\n if (this._subsTopics.has(this._requests[data[1]].topic)) {\n this._subsTopics.delete(this._requests[data[1]].topic);\n }\n\n if (this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n }\n break;\n case WAMP_MSG_SPEC.PUBLISHED:\n // WAMP SPEC: [PUBLISHED, PUBLISH.Request|id, Publication|id]\n if (this._requests[data[1]]) {\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n case WAMP_MSG_SPEC.EVENT:\n if (this._subscriptions[data[1]]) {\n\n // WAMP SPEC: [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id,\n // Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentKw|dict]\n\n i = this._subscriptions[data[1]].callbacks.length;\n while (i--) {\n this._subscriptions[data[1]].callbacks[i](data[4], data[5]);\n }\n\n }\n break;\n case WAMP_MSG_SPEC.RESULT:\n if (this._calls[data[1]]) {\n\n // WAMP SPEC: [RESULT, CALL.Request|id, Details|dict,\n // YIELD.Arguments|list, YIELD.ArgumentsKw|dict]\n\n this._calls[data[1]].onSuccess(data[3], data[4]);\n if (!(data[2].progress && data[2].progress === true)) {\n // We receive final result (progressive or not)\n delete this._calls[data[1]];\n }\n\n }\n break;\n // case WAMP_MSG_SPEC.REGISTER:\n // // WAMP SPEC:\n // break;\n case WAMP_MSG_SPEC.REGISTERED:\n // WAMP SPEC: [REGISTERED, REGISTER.Request|id, Registration|id]\n if (this._requests[data[1]]) {\n this._rpcRegs[this._requests[data[1]].topic] = this._rpcRegs[data[2]] = {\n id: data[2],\n callbacks: [this._requests[data[1]].callbacks.rpc]\n };\n\n this._rpcNames.add(this._requests[data[1]].topic);\n\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n\n }\n break;\n // case WAMP_MSG_SPEC.UNREGISTER:\n // // WAMP SPEC:\n // break;\n case WAMP_MSG_SPEC.UNREGISTERED:\n // WAMP SPEC: [UNREGISTERED, UNREGISTER.Request|id]\n if (this._requests[data[1]]) {\n id = this._rpcRegs[this._requests[data[1]].topic].id;\n delete this._rpcRegs[this._requests[data[1]].topic];\n delete this._rpcRegs[id];\n\n if (this._rpcNames.has(this._requests[data[1]].topic)) {\n this._rpcNames.delete(this._requests[data[1]].topic);\n }\n\n if (this._requests[data[1]].callbacks && this._requests[data[1]].callbacks.onSuccess) {\n this._requests[data[1]].callbacks.onSuccess();\n }\n\n delete this._requests[data[1]];\n }\n break;\n case WAMP_MSG_SPEC.INVOCATION:\n if (this._rpcRegs[data[2]]) {\n\n // WAMP SPEC: [INVOCATION, Request|id, REGISTERED.Registration|id,\n // Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict]\n\n p = new Promise((resolve, reject) => {\n resolve(this._rpcRegs[data[2]].callbacks[0](data[4], data[5], data[3]));\n });\n\n p.then((results) => {\n // WAMP SPEC: [YIELD, INVOCATION.Request|id, Options|dict, (Arguments|list, ArgumentsKw|dict)]\n msg = [WAMP_MSG_SPEC.YIELD, data[1], {}];\n if (this._isArray(results)) {\n // Options\n if (this._isPlainObject(results[0])) {\n msg[2] = results[0];\n }\n\n if (this._isArray(results[1])) {\n msg.push(results[1]);\n } else if (typeof (results[1]) !== 'undefined') {\n msg.push([results[1]]);\n }\n\n if (this._isPlainObject(results[2])) {\n if (msg.length === 3) {\n msg.push([]);\n }\n msg.push(results[2]);\n }\n } else {\n msg = [WAMP_MSG_SPEC.YIELD, data[1], {}];\n }\n this._send(msg);\n\n }).catch(e => {\n let msg = [WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.INVOCATION,\n data[1], e.details || {}, e.uri || 'wamp.error.invocation_exception'];\n\n if (e.argsList && this._isArray(e.argsList)) {\n msg.push(e.argsList);\n }\n\n if (e.argsDict && this._isPlainObject(e.argsDict)) {\n if (msg.length === 5) {\n msg.push([]);\n }\n msg.push(e.argsDict);\n }\n this._send(msg);\n });\n\n } else {\n // WAMP SPEC: [ERROR, INVOCATION, INVOCATION.Request|id, Details|dict, Error|uri]\n this._send([WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.INVOCATION,\n data[1], {}, 'wamp.error.no_such_procedure']);\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_INVOCATION;\n }\n\n break;\n // case WAMP_MSG_SPEC.INTERRUPT:\n // // WAMP SPEC:\n // break;\n // case WAMP_MSG_SPEC.YIELD:\n // // WAMP SPEC:\n // break;\n default:\n this._log('[wampy] Received non-compliant WAMP message');\n break;\n }\n }\n\n /**\n * Internal websocket on error callback\n * @param {object} error\n * @private\n */\n _wsOnError (error) {\n this._log('[wampy] websocket error');\n\n if (this._options.onError) {\n this._options.onError(error);\n }\n }\n\n /**\n * Reconnect to server in case of websocket error\n * @private\n */\n _wsReconnect () {\n this._log('[wampy] websocket reconnecting...');\n\n if (this._options.onReconnect) {\n this._options.onReconnect();\n }\n\n this._cache.reconnectingAttempts++;\n this._ws = getWebSocket(this._url, this._protocols, this._options.ws);\n this._initWsCallbacks();\n }\n\n /**\n * Resubscribe to topics in case of communication error\n * @private\n */\n _renewSubscriptions () {\n let i;\n const subs = this._subscriptions,\n st = this._subsTopics;\n\n this._subscriptions = {};\n this._subsTopics = new Set();\n\n for (let topic of st) {\n i = subs[topic].callbacks.length;\n while (i--) {\n this.subscribe(topic, subs[topic].callbacks[i]);\n }\n }\n }\n\n /**\n * Reregister RPCs in case of communication error\n * @private\n */\n _renewRegistrations () {\n const rpcs = this._rpcRegs,\n rn = this._rpcNames;\n\n this._rpcRegs = {};\n this._rpcNames = new Set();\n\n for (let rpcName of rn) {\n this.register(rpcName, { rpc: rpcs[rpcName].callbacks[0] });\n }\n }\n\n /* Wampy public API */\n\n /**\n * Get or set Wampy options\n *\n * To get options - call without parameters\n * To set options - pass hash-table with options values\n *\n * @param {object} opts\n * @returns {*}\n */\n options (opts) {\n if (typeof (opts) === 'undefined') {\n return this._options;\n } else if (this._isPlainObject(opts)) {\n this._options = this._merge(this._options, opts);\n return this;\n }\n }\n\n /**\n * Get the status of last operation\n *\n * @returns {object} with 2 fields: code, description\n * code: 0 - if operation was successful\n * code > 0 - if error occurred\n * description contains details about error\n * reqId: last send request ID\n */\n getOpStatus () {\n return this._cache.opStatus;\n }\n\n /**\n * Get the WAMP Session ID\n *\n * @returns {string} Session ID\n */\n getSessionId () {\n return this._cache.sessionId;\n }\n\n /**\n * Connect to server\n * @param {string} url New url (optional)\n * @returns {Wampy}\n */\n connect (url) {\n if (url) {\n this._url = url;\n }\n\n if (this._options.realm) {\n\n const authp = (this._options.authid ? 1 : 0) +\n ((this._isArray(this._options.authmethods) && this._options.authmethods.length) ? 1 : 0) +\n (typeof this._options.onChallenge === 'function' ? 1 : 0);\n\n if (authp > 0 && authp < 3) {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CRA_CB_OR_ID;\n return this;\n }\n\n this._setWsProtocols();\n this._ws = getWebSocket(this._url, this._protocols, this._options.ws);\n if (!this._ws) {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_WS_OR_URL;\n return this;\n }\n this._initWsCallbacks();\n\n } else {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_REALM;\n }\n\n return this;\n }\n\n /**\n * Disconnect from server\n * @returns {Wampy}\n */\n disconnect () {\n if (this._cache.sessionId) {\n // need to send goodbye message to server\n this._cache.isSayingGoodbye = true;\n this._send([WAMP_MSG_SPEC.GOODBYE, {}, 'wamp.error.system_shutdown']);\n } else if (this._ws) {\n this._ws.close();\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n\n return this;\n }\n\n /**\n * Abort WAMP session establishment\n *\n * @returns {Wampy}\n */\n abort () {\n\n if (!this._cache.sessionId && this._ws.readyState === 1) {\n this._send([WAMP_MSG_SPEC.ABORT, {}, 'wamp.error.abort']);\n this._cache.sessionId = null;\n }\n\n this._ws.close();\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n\n return this;\n }\n\n /**\n * Subscribe to a topic on a broker\n *\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as published event callback\n * or it can be hash table of callbacks:\n * { onSuccess: will be called when subscribe would be confirmed\n * onError: will be called if subscribe would be aborted\n * onEvent: will be called on receiving published event }\n *\n * @returns {Wampy}\n */\n subscribe (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'broker', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onEvent: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onEvent) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (!this._subscriptions[topicURI] || !this._subscriptions[topicURI].callbacks.length) {\n // no such subscription or processing unsubscribing\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]\n this._send([WAMP_MSG_SPEC.SUBSCRIBE, reqId, {}, topicURI]);\n\n } else { // already have subscription to this topic\n // There is no such callback yet\n if (this._subscriptions[topicURI].callbacks.indexOf(callbacks.onEvent) < 0) {\n this._subscriptions[topicURI].callbacks.push(callbacks.onEvent);\n }\n\n if (callbacks.onSuccess) {\n callbacks.onSuccess();\n }\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Unsubscribe from topic\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as\n * published event callback to remove or it can be hash table of callbacks:\n * { onSuccess: will be called when unsubscribe would be confirmed\n * onError: will be called if unsubscribe would be aborted\n * onEvent: published event callback to remove }\n * @returns {Wampy}\n */\n unsubscribe (topicURI, callbacks) {\n let reqId, i = -1;\n\n if (!this._preReqChecks(null, 'broker', callbacks)) {\n return this;\n }\n\n if (this._subscriptions[topicURI]) {\n\n reqId = this._getReqId();\n\n if (typeof (callbacks) === 'undefined') {\n this._subscriptions[topicURI].callbacks = [];\n callbacks = {};\n } else if (typeof callbacks === 'function') {\n i = this._subscriptions[topicURI].callbacks.indexOf(callbacks);\n callbacks = {};\n } else if (callbacks.onEvent && typeof callbacks.onEvent === 'function') {\n i = this._subscriptions[topicURI].callbacks.indexOf(callbacks.onEvent);\n } else {\n this._subscriptions[topicURI].callbacks = [];\n }\n\n if (i >= 0) {\n this._subscriptions[topicURI].callbacks.splice(i, 1);\n }\n\n if (this._subscriptions[topicURI].callbacks.length) {\n // There are another callbacks for this topic\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n return this;\n }\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP_SPEC: [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]\n this._send([WAMP_MSG_SPEC.UNSUBSCRIBE, reqId, this._subscriptions[topicURI].id]);\n\n } else {\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_UNSUBSCRIBE;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Publish a event to topic\n * @param {string} topicURI\n * @param {string|number|Array|object} payload - optional parameter.\n * @param {object} callbacks - optional hash table of callbacks:\n * { onSuccess: will be called when publishing would be confirmed\n * onError: will be called if publishing would be aborted }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { exclude: integer|array WAMP session id(s) that won't receive a published event,\n * even though they may be subscribed\n * exclude_authid: string|array Authentication id(s) that won't receive\n * a published event, even though they may be subscribed\n * exclude_authrole: string|array Authentication role(s) that won't receive\n * a published event, even though they may be subscribed\n * eligible: integer|array WAMP session id(s) that are allowed\n * to receive a published event\n * eligible_authid: string|array Authentication id(s) that are allowed\n * to receive a published event\n * eligible_authrole: string|array Authentication role(s) that are allowed\n * to receive a published event\n * exclude_me: bool flag of receiving publishing event by initiator\n * disclose_me: bool flag of disclosure of publisher identity (its WAMP session ID)\n * to receivers of a published event }\n * @returns {Wampy}\n */\n publish (topicURI, payload, callbacks, advancedOptions) {\n let reqId, msg, err = false;\n const options = {};\n\n if (!this._preReqChecks(topicURI, 'broker', callbacks)) {\n return this;\n }\n\n if (this._isPlainObject(callbacks)) {\n options.acknowledge = true;\n }\n\n if (typeof (advancedOptions) !== 'undefined') {\n\n if (this._isPlainObject(advancedOptions)) {\n if (advancedOptions.exclude) {\n if (this._isArray(advancedOptions.exclude) && advancedOptions.exclude.length) {\n options.exclude = advancedOptions.exclude;\n } else if (typeof advancedOptions.exclude === 'number') {\n options.exclude = [advancedOptions.exclude];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.exclude_authid) {\n if (this._isArray(advancedOptions.exclude_authid) && advancedOptions.exclude_authid.length) {\n options.exclude_authid = advancedOptions.exclude_authid;\n } else if (typeof advancedOptions.exclude_authid === 'string') {\n options.exclude_authid = [advancedOptions.exclude_authid];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.exclude_authrole) {\n if (this._isArray(advancedOptions.exclude_authrole) && advancedOptions.exclude_authrole.length) {\n options.exclude_authrole = advancedOptions.exclude_authrole;\n } else if (typeof advancedOptions.exclude_authrole === 'string') {\n options.exclude_authrole = [advancedOptions.exclude_authrole];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible) {\n if (this._isArray(advancedOptions.eligible) && advancedOptions.eligible.length) {\n options.eligible = advancedOptions.eligible;\n } else if (typeof advancedOptions.eligible === 'number') {\n options.eligible = [advancedOptions.eligible];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible_authid) {\n if (this._isArray(advancedOptions.eligible_authid) && advancedOptions.eligible_authid.length) {\n options.eligible_authid = advancedOptions.eligible_authid;\n } else if (typeof advancedOptions.eligible_authid === 'string') {\n options.eligible_authid = [advancedOptions.eligible_authid];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.eligible_authrole) {\n if (this._isArray(advancedOptions.eligible_authrole) && advancedOptions.eligible_authrole.length) {\n options.eligible_authrole = advancedOptions.eligible_authrole;\n } else if (typeof advancedOptions.eligible_authrole === 'string') {\n options.eligible_authrole = [advancedOptions.eligible_authrole];\n } else {\n err = true;\n }\n }\n\n if (advancedOptions.hasOwnProperty('exclude_me')) {\n options.exclude_me = advancedOptions.exclude_me !== false;\n }\n\n if (advancedOptions.hasOwnProperty('disclose_me')) {\n options.disclose_me = advancedOptions.disclose_me === true;\n }\n\n } else {\n err = true;\n }\n\n if (err) {\n this._cache.opStatus = WAMP_ERROR_MSG.INVALID_PARAM;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n }\n\n reqId = this._getReqId();\n\n switch (arguments.length) {\n case 1:\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri]\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI];\n break;\n case 2:\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list (, ArgumentsKw|dict)]\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [payload]];\n }\n break;\n default:\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP_SPEC: [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list (, ArgumentsKw|dict)]\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.PUBLISH, reqId, options, topicURI, [payload]];\n }\n break;\n }\n\n this._send(msg);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * Remote Procedure Call\n * @param {string} topicURI\n * @param {string|number|Array|object} payload - can be either a value of any type or null\n * @param {function|object} callbacks - if it is a function - it will be treated as result callback function\n * or it can be hash table of callbacks:\n * { onSuccess: will be called with result on successful call\n * onError: will be called if invocation would be aborted }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { disclose_me: bool flag of disclosure of Caller identity (WAMP session ID)\n * to endpoints of a routed call\n * receive_progress: bool flag for receiving progressive results. In this case\n * onSuccess function will be called every time on receiving result\n * timeout: integer timeout (in ms) for the call to finish }\n * @returns {Wampy}\n */\n call (topicURI, payload, callbacks, advancedOptions) {\n let reqId, msg, err = false;\n const options = {};\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onSuccess: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onSuccess) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (typeof (advancedOptions) !== 'undefined') {\n\n if (this._isPlainObject(advancedOptions)) {\n if (advancedOptions.hasOwnProperty('disclose_me')) {\n options.disclose_me = advancedOptions.disclose_me === true;\n }\n\n if (advancedOptions.hasOwnProperty('receive_progress')) {\n options.receive_progress = advancedOptions.receive_progress === true;\n }\n\n if (advancedOptions.hasOwnProperty('timeout')) {\n if (typeof advancedOptions.timeout === 'number') {\n options.timeout = advancedOptions.timeout;\n } else {\n err = true;\n }\n }\n\n } else {\n err = true;\n }\n\n if (err) {\n this._cache.opStatus = WAMP_ERROR_MSG.INVALID_PARAM;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n }\n\n do {\n reqId = this._getReqId();\n } while (reqId in this._calls);\n\n this._calls[reqId] = callbacks;\n\n // WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri, (Arguments|list, ArgumentsKw|dict)]\n if (payload === null) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI];\n } else {\n if (this._isArray(payload)) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, payload];\n } else if (this._isPlainObject(payload)) {\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, [], payload];\n } else { // assume it's a single value\n msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI, [payload]];\n }\n }\n\n this._send(msg);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n return this;\n }\n\n /**\n * RPC invocation cancelling\n *\n * @param {int} reqId RPC call request ID\n * @param {function|object} callbacks - if it is a function - it will be called if successfully\n * sent canceling message or it can be hash table of callbacks:\n * { onSuccess: will be called if successfully sent canceling message\n * onError: will be called if some error occurred }\n * @param {object} advancedOptions - optional parameter. Must include any or all of the options:\n * { mode: string|one of the possible modes:\n * \"skip\" | \"kill\" | \"killnowait\". Skip is default.\n * }\n *\n * @returns {Wampy}\n */\n cancel (reqId, callbacks, advancedOptions) {\n const options = { mode: 'skip' };\n\n if (!this._preReqChecks(null, 'dealer', callbacks)) {\n return this;\n }\n\n if (!reqId || !this._calls[reqId]) {\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_REQ_ID;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if ((typeof (advancedOptions) !== 'undefined') &&\n (this._isPlainObject(advancedOptions)) &&\n (advancedOptions.hasOwnProperty('mode'))) {\n\n options.mode = /skip|kill|killnowait/.test(advancedOptions.mode) ? advancedOptions.mode : 'skip';\n }\n\n // WAMP SPEC: [CANCEL, CALL.Request|id, Options|dict]\n this._send([WAMP_MSG_SPEC.CANCEL, reqId, options]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n\n callbacks.onSuccess && callbacks.onSuccess();\n\n return this;\n }\n\n /**\n * RPC registration for invocation\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function - it will be treated as rpc itself\n * or it can be hash table of callbacks:\n * { rpc: registered procedure\n * onSuccess: will be called on successful registration\n * onError: will be called if registration would be aborted }\n * @returns {Wampy}\n */\n register (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { rpc: callbacks };\n } else if (!this._isPlainObject(callbacks) || typeof (callbacks.rpc) === 'undefined') {\n this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n return this;\n }\n\n if (!this._rpcRegs[topicURI] || !this._rpcRegs[topicURI].callbacks.length) {\n // no such registration or processing unregistering\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [REGISTER, Request|id, Options|dict, Procedure|uri]\n this._send([WAMP_MSG_SPEC.REGISTER, reqId, {}, topicURI]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n } else { // already have registration with such topicURI\n this._cache.opStatus = WAMP_ERROR_MSG.RPC_ALREADY_REGISTERED;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n }\n\n return this;\n\n }\n\n /**\n * RPC unregistration for invocation\n * @param {string} topicURI\n * @param {function|object} callbacks - if it is a function, it will be called on successful unregistration\n * or it can be hash table of callbacks:\n * { onSuccess: will be called on successful unregistration\n * onError: will be called if unregistration would be aborted }\n * @returns {Wampy}\n */\n unregister (topicURI, callbacks) {\n let reqId;\n\n if (!this._preReqChecks(topicURI, 'dealer', callbacks)) {\n return this;\n }\n\n if (typeof callbacks === 'function') {\n callbacks = { onSuccess: callbacks };\n }\n\n if (this._rpcRegs[topicURI]) { // there is such registration\n\n reqId = this._getReqId();\n\n this._requests[reqId] = {\n topic: topicURI,\n callbacks: callbacks\n };\n\n // WAMP SPEC: [UNREGISTER, Request|id, REGISTERED.Registration|id]\n this._send([WAMP_MSG_SPEC.UNREGISTER, reqId, this._rpcRegs[topicURI].id]);\n this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;\n this._cache.opStatus.reqId = reqId;\n } else { // there is no registration with such topicURI\n this._cache.opStatus = WAMP_ERROR_MSG.NON_EXIST_RPC_UNREG;\n\n if (this._isPlainObject(callbacks) && callbacks.onError) {\n callbacks.onError(this._cache.opStatus.description);\n }\n\n }\n\n return this;\n }\n}\n\nexport default Wampy;\nexport { Wampy };\n"]} \ No newline at end of file diff --git a/package.json b/package.json index e048f99..f6396b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wampy", - "version": "4.1.0", + "version": "5.0.0", "description": "Simple WAMP (WebSocket Application Messaging Protocol) Javascript implementation", "author": "Konstantin Burkalev (http://ksdaemon.ru)", "devDependencies": { diff --git a/src/wampy.js b/src/wampy.js index ac0b262..5f488f4 100644 --- a/src/wampy.js +++ b/src/wampy.js @@ -35,7 +35,7 @@ class Wampy { * @type {string} * @private */ - this.version = 'v4.1.0'; + this.version = 'v5.0.0'; /** * WS Url