Skip to content

Commit 9a324b1

Browse files
committed
通知テスト
1 parent 4670ad5 commit 9a324b1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/backend/src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from 'path';
55
import { errorHandler } from './middlewares/errorHandler';
66
import { logger } from '@/utils/logger';
77
import { WebSocketDonChannel } from './websocket/donChannel';
8+
import { Don } from './websocket/messages';
89

910
const app = express();
1011

@@ -71,6 +72,16 @@ const server = app.listen(port, host, () => {
7172
const donChannel = new WebSocketDonChannel({ wssConfig: { port: 52601 } });
7273
logger.info('WebSocket server started on ws://localhost:52601');
7374

75+
// 5秒ごとに通知をテスト送信
76+
setInterval(() => {
77+
logger.info('Sending notification to active clients...');
78+
const exampleDonState: Don[] = [
79+
{ id: '1', state: 'ordered' },
80+
{ id: '2', state: 'cooking' },
81+
];
82+
donChannel.notifyActiveDonState(exampleDonState);
83+
}, 5000);
84+
7485
// Graceful shutdown
7586
process.on('SIGTERM', () => {
7687
logger.info('SIGTERM signal received: closing HTTP server');

0 commit comments

Comments
 (0)