node_modules/binance/lib/websocket-client.js
/**
     * Subscribe to margin user data stream - listen key is automatically generated.
     */
Subscribe to margin user data stream - listen key is automatically generated.
Subscribe to margin user data stream - listen key is automatically generated .
subscribeMarginUserDataStream(forceNewConnection, isReconnecting) {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                const { listenKey } = yield this.getSpotRestClient().getMarginUserDataListenKey();
                const market = 'margin';
                const wsKey = requestUtils_1.getWsKeyWithContext(market, 'userData', undefined, listenKey);
                this.setWsState(wsKey, isReconnecting ? READY_STATE_RECONNECTING : READY_STATE_CONNECTING);
                const ws = this.connectToWsUrl(this.getWsBaseUrl(market, wsKey) + `/ws/${listenKey}`, wsKey, forceNewConnection);
                this.setKeepAliveListenKeyTimer(listenKey, market, ws, wsKey);
                return ws;
            }
            catch (e) {
                this.logger.error(`Failed to get margin user data listen key`, Object.assign(Object.assign({}, loggerCategory), { error: e }));
                throw e;
            }
        });
    }
subscribeMarginUserDataStream ( forceNewConnection , isReconnecting ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { try { const { listenKey } = yield this . getSpotRestClient ( ) . getMarginUserDataListenKey ( ) ; const market = 'margin' ; const wsKey = requestUtils_1 . getWsKeyWithContext ( market , 'userData' , undefined , listenKey ) ; this . setWsState ( wsKey , isReconnecting ? READY_STATE_RECONNECTING : READY_STATE_CONNECTING ) ; const ws = this . connectToWsUrl ( this . getWsBaseUrl ( market , wsKey ) + ` ${ listenKey } ` , wsKey , forceNewConnection ) ; this . setKeepAliveListenKeyTimer ( listenKey , market , ws , wsKey ) ; return ws ; } catch ( e ) { this . logger . error ( ` ` , Object . assign ( Object . assign ( { } , loggerCategory ) , { error : e } ) ) ; throw e ; } } ) ; }
Subscribe to margin user data stream - listen key is automatically generated.
Subscribe to margin user data stream - listen key is automatically generated .
// Start & store timer to keep alive listen key (and handle expiration)