src/wampy.js
/**
     * Remote Procedure Call
     * @param {string} topicURI
     * @param {string|number|Array|object} payload - can be either a value of any type or null.  Also it
     *                          is possible to pass array and object-like data simultaneously.
     *                          In this case pass a hash-table with next attributes:
     *                          {
     *                             argsList: array payload (may be omitted)
     *                             argsDict: object payload (may be omitted)
     *                          }
     * @param {function|object} callbacks - if it is a function - it will be treated as result callback function
     *                          or it can be hash table of callbacks:
     *                          { onSuccess: will be called with result on successful call
     *                            onError: will be called if invocation would be aborted }
     * @param {object} advancedOptions - optional parameter. Must include any or all of the options:
     *                          { disclose_me: bool flag of disclosure of Caller identity (WAMP session ID)
     *                                  to endpoints of a routed call
     *                            receive_progress: bool flag for receiving progressive results. In this case
     *                                  onSuccess function will be called every time on receiving result
     *                            timeout: integer timeout (in ms) for the call to finish }
     * @returns {Wampy}
     */
Remote Procedure Call
@param {string} topicURI
@param {string|number|Array|object} payload - can be either a value of any type or null.  Also it
is possible to pass array and object-like data simultaneously.
Remote Procedure Call @param { string } topicURI @param { string|number|Array|object } payload - can be either a value of any type or null . Also it is possible to pass array and object - like data simultaneously .
call (topicURI, payload, callbacks, advancedOptions) {
        let reqId, msg, err = false;
        const options = {};
        if (!this._preReqChecks({ topic: topicURI, patternBased: false, allowWAMP: true }, 'dealer', callbacks)) {
            return this;
        }
        if (typeof callbacks === 'function') {
            callbacks = { onSuccess: callbacks };
        } else if (!this._isPlainObject(callbacks) || typeof (callbacks.onSuccess) === 'undefined') {
            this._cache.opStatus = WAMP_ERROR_MSG.NO_CALLBACK_SPEC;
            if (this._isPlainObject(callbacks) && callbacks.onError) {
                callbacks.onError({ error: this._cache.opStatus.description });
            }
            return this;
        }
        if (typeof (advancedOptions) !== 'undefined') {
            if (this._isPlainObject(advancedOptions)) {
                if (Object.hasOwnProperty.call(advancedOptions, 'disclose_me')) {
                    options.disclose_me = advancedOptions.disclose_me === true;
                }
                if (Object.hasOwnProperty.call(advancedOptions, 'receive_progress')) {
                    options.receive_progress = advancedOptions.receive_progress === true;
                }
                if (Object.hasOwnProperty.call(advancedOptions, 'timeout')) {
                    if (typeof advancedOptions.timeout === 'number') {
                        options.timeout = advancedOptions.timeout;
                    } else {
                        err = true;
                    }
                }
            } else {
                err = true;
            }
            if (err) {
                this._cache.opStatus = WAMP_ERROR_MSG.INVALID_PARAM;
                if (this._isPlainObject(callbacks) && callbacks.onError) {
                    callbacks.onError({ error: this._cache.opStatus.description });
                }
                return this;
            }
        }
        do {
            reqId = this._getReqId();
        } while (reqId in this._calls);
        this._calls[reqId] = callbacks;
        msg = [WAMP_MSG_SPEC.CALL, reqId, options, topicURI];
        if (payload !== null && typeof (payload) !== 'undefined') {
            if (this._isArray(payload)) {
                msg.push(payload);
            } else if (this._isPlainObject(payload)) {
                if (payload.argsList || payload.argsDict) {
                    if (payload.argsList) {
                        msg.push(payload.argsList);
                    }
                    if (payload.argsDict) {
                        if (msg.length === 4) {
                            msg.push([]);
                        }
                        msg.push(payload.argsDict);
                    }
                } else {
                    msg.push([], payload);
                }
            } else {    
                msg.push([payload]);
            }
        }
        this._send(msg);
        this._cache.opStatus = WAMP_ERROR_MSG.SUCCESS;
        this._cache.opStatus.reqId = reqId;
        return this;
    }
call ( topicURI , payload , callbacks , advancedOptions ) { let reqId , msg , err = false ; const options = { } ; if ( ! this . _preReqChecks ( { topic : topicURI , patternBased : false , allowWAMP : true } , 'dealer' , callbacks ) ) { return this ; } if ( typeof callbacks === 'function' ) { callbacks = { onSuccess : callbacks } ; } else if ( ! this . _isPlainObject ( callbacks ) || typeof ( callbacks . onSuccess ) === 'undefined' ) { this . _cache . opStatus = WAMP_ERROR_MSG . NO_CALLBACK_SPEC ; if ( this . _isPlainObject ( callbacks ) && callbacks . onError ) { callbacks . onError ( { error : this . _cache . opStatus . description } ) ; } return this ; } if ( typeof ( advancedOptions ) !== 'undefined' ) { if ( this . _isPlainObject ( advancedOptions ) ) { if ( Object . hasOwnProperty . call ( advancedOptions , 'disclose_me' ) ) { options . disclose_me = advancedOptions . disclose_me === true ; } if ( Object . hasOwnProperty . call ( advancedOptions , 'receive_progress' ) ) { options . receive_progress = advancedOptions . receive_progress === true ; } if ( Object . hasOwnProperty . call ( advancedOptions , 'timeout' ) ) { if ( typeof advancedOptions . timeout === 'number' ) { options . timeout = advancedOptions . timeout ; } else { err = true ; } } } else { err = true ; } if ( err ) { this . _cache . opStatus = WAMP_ERROR_MSG . INVALID_PARAM ; if ( this . _isPlainObject ( callbacks ) && callbacks . onError ) { callbacks . onError ( { error : this . _cache . opStatus . description } ) ; } return this ; } } do { reqId = this . _getReqId ( ) ; } while ( reqId in this . _calls ) ; this . _calls [ reqId ] = callbacks ; msg = [ WAMP_MSG_SPEC . CALL , reqId , options , topicURI ] ; if ( payload !== null && typeof ( payload ) !== 'undefined' ) { if ( this . _isArray ( payload ) ) { msg . push ( payload ) ; } else if ( this . _isPlainObject ( payload ) ) { if ( payload . argsList || payload . argsDict ) { if ( payload . argsList ) { msg . push ( payload . argsList ) ; } if ( payload . argsDict ) { if ( msg . length === 4 ) { msg . push ( [ ] ) ; } msg . push ( payload . argsDict ) ; } } else { msg . push ( [ ] , payload ) ; } } else { msg . push ( [ payload ] ) ; } } this . _send ( msg ) ; this . _cache . opStatus = WAMP_ERROR_MSG . SUCCESS ; this . _cache . opStatus . reqId = reqId ; return this ; }
Remote Procedure Call
 @param {string} topicURI
 @param {string|number|Array|object} payload - can be either a value of any type or null.
Remote Procedure Call @param { string } topicURI @param { string|number|Array|object } payload - can be either a value of any type or null .
// WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri, (Arguments|list, ArgumentsKw|dict)] // It's a wampy unified form of payload passing // assume it's a single value