src/wampy.js
/**
     * Internal websocket on open callback
     * @private
     */
Internal websocket on open callback
@private
Internal websocket on open callback @private
_wsOnOpen () {
        const options = this._merge(this._options.helloCustomDetails, this._wamp_features),
            serverProtocol = this._ws.protocol ? this._ws.protocol.split('.')[2] : '';
        if (this._options.authid) {
            options.authmethods = this._options.authmethods;
            options.authid = this._options.authid;
        }
        this._log('[wampy] websocket connected');
        if (this._options.serializer.protocol !== serverProtocol) {
            if (serverProtocol === 'json' ||
                (typeof navigator != 'undefined' &&
                    navigator.product === 'ReactNative' &&
                    typeof this._ws.protocol === 'undefined')) {
                this._options.serializer = new JsonSerializer();
            } else {
                this._cache.opStatus = WAMP_ERROR_MSG.NO_SERIALIZER_AVAILABLE;
                return this;
            }
        }
        if (this._options.serializer.isBinary) {
            this._ws.binaryType = 'arraybuffer';
        }
        this._ws.send(this._encode([WAMP_MSG_SPEC.HELLO, this._options.realm, options]));
    }
_wsOnOpen ( ) { const options = this . _merge ( this . _options . helloCustomDetails , this . _wamp_features ) , serverProtocol = this . _ws . protocol ? this . _ws . protocol . split ( '.' ) [ 2 ] : '' ; if ( this . _options . authid ) { options . authmethods = this . _options . authmethods ; options . authid = this . _options . authid ; } this . _log ( '[wampy] websocket connected' ) ; if ( this . _options . serializer . protocol !== serverProtocol ) { if ( serverProtocol === 'json' || ( typeof navigator != 'undefined' && navigator . product === 'ReactNative' && typeof this . _ws . protocol === 'undefined' ) ) { this . _options . serializer = new JsonSerializer ( ) ; } else { this . _cache . opStatus = WAMP_ERROR_MSG . NO_SERIALIZER_AVAILABLE ; return this ; } } if ( this . _options . serializer . isBinary ) { this . _ws . binaryType = 'arraybuffer' ; } this . _ws . send ( this . _encode ( [ WAMP_MSG_SPEC . HELLO , this . _options . realm , options ] ) ) ; }
Internal websocket on open callback
 @private
Internal websocket on open callback @private
// Server have chosen not our preferred protocol // Falling back to json if possible //FIXME Temp hack for React Native Environment. // Due to bug (facebook/react-native#24796), it doesn't provide selected subprotocol. // Remove when ^^^ bug will be fixed. // WAMP SPEC: [HELLO, Realm|uri, Details|dict] // Sending directly 'cause it's a hello msg and no sessionId check is needed