Skip to content

Commit

Permalink
Revert "🐛 fix: stock gateway 수정, websocket - client 서빙 구조 변경"
Browse files Browse the repository at this point in the history
This reverts commit 441926f.
  • Loading branch information
swkim12345 committed Nov 24, 2024
1 parent 973733b commit cdfd1f8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import { ScraperModule } from './scraper/scraper.module';
import { AuthModule } from '@/auth/auth.module';
import { SessionModule } from '@/auth/session.module';
import { ChatModule } from '@/chat/chat.module';
import { logger } from '@/configs/logger.config';
import {
typeormDevelopConfig,
typeormProductConfig,
} from '@/configs/typeormConfig';
import { logger } from '@/configs/logger.config';
import { StockModule } from '@/stock/stock.module';
import { UserModule } from '@/user/user.module';

@Module({
imports: [
ConfigModule.forRoot({ cache: true, isGlobal: true }),
ScheduleModule.forRoot(),
ScraperModule,
StockModule,
UserModule,
TypeOrmModule.forRoot(
process.env.NODE_ENV === 'production'
? typeormProductConfig
: typeormDevelopConfig,
),
ScraperModule,
StockModule,
UserModule,
WinstonModule.forRoot(logger),
AuthModule,
ChatModule,
Expand Down
10 changes: 2 additions & 8 deletions packages/backend/src/stock/stock.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@ import {
WebSocketServer,
} from '@nestjs/websockets';
import { Server, Socket } from 'socket.io';
import { WebsocketClient } from '@/scraper/openapi/websocketClient.service';

@WebSocketGateway({
namespace: '/api/stock/realtime',
cors: true,
transports: ['websocket'],
})
export class StockGateway {
@WebSocketServer()
server: Server;

constructor(private readonly websocketClient: WebsocketClient) {}
constructor() {}

@SubscribeMessage('connectStock')
async handleConnectStock(
handleConnectStock(
@MessageBody() stockId: string,
@ConnectedSocket() client: Socket,
) {
client.join(stockId);

if ((await this.server.in(stockId).fetchSockets()).length === 0) {
this.websocketClient.subscribe(stockId);
}
client.emit('connectionSuccess', {
message: `Successfully connected to stock room: ${stockId}`,
stockId,
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/stock/stock.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from './stockData.service';
import { StockDetailService } from './stockDetail.service';
import { StockLiveDataSubscriber } from './stockLiveData.subscriber';
import { OpenapiScraperModule } from '@/scraper/openapi/openapi-scraper.module';

@Module({
imports: [
Expand All @@ -37,7 +36,6 @@ import { OpenapiScraperModule } from '@/scraper/openapi/openapi-scraper.module';
StockLiveData,
StockDetail,
]),
OpenapiScraperModule,
],
controllers: [StockController],
providers: [
Expand Down

0 comments on commit cdfd1f8

Please sign in to comment.