blockcoders / nestjs-websocket

Websocket Client for NestJS based on ws
Apache License 2.0
21 stars 12 forks source link

How can I use Multiple Websocket Client with your great package? #6

Open godtaehee opened 2 years ago

godtaehee commented 2 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I import two WebSocketModule in each different module like below code.

// upbit.module.ts
import { Module } from '@nestjs/common';
import { UpbitService } from './upbit.service';
import { WebSocketModule } from 'nestjs-websocket';
import { UpbitWebsocketClient } from './upbitWebsocketClient';

@Module({
  imports: [
    WebSocketModule.forRoot({
      url: 'wss://api.upbit.com/websocket/v1',
    }),
  ],
  providers: [UpbitService, UpbitWebsocketClient],
  exports: [UpbitWebsocketClient],
})
export class UpbitModule {}
// binance.module.ts
import { Module } from '@nestjs/common';
import { WebSocketModule } from 'nestjs-websocket';
import { BinanceService } from './binance.service';
import { BinanceWebsocketClient } from './binanceWebsocketClient';

@Module({
  imports: [
    WebSocketModule.forRoot({
      url: 'wss://stream.binance.com:9443/ws/btcusdt@trade',
    }),
  ],
  providers: [BinanceService, BinanceWebsocketClient],
  exports: [BinanceWebsocketClient],
})
export class BinanceModule {}

Expected behavior

I expected that I can use both websocket clients because I imported two websocket clients which have different url in each module(upbit.module, binance.module).

But I can only use binance websocket client.

Minimal reproduction of the problem with instructions

I don't have it.

What is the motivation / use case for changing the behavior?

We can get the information from many different WebSocket Clients.

Environment


Nest version: X.Y.Z
Nest WebSocket: X.Y.Z


For Tooling issues:
- Node version: v16.16.0
- Platform: Mac
- Server: Express

Others:

vadimoarturo commented 1 year ago

Up! The problem is that one token is locked on the provider, and then the token injection is hidden behind the decorator

image image

0xslipk commented 1 year ago

I will take a look an release a version.