-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
34 lines (26 loc) · 816 Bytes
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { io } from "socket.io-client";
import { toSocketIo } from "@mswjs/socket.io-binding";
import { ws } from "msw";
import { setupWorker } from "msw/browser";
const chat = ws.link("ws://localhost:3000/socket.io/");
export const handlers = [
chat.addEventListener("connection", (connection) => {
const io = toSocketIo(connection);
io.client.on("connect", () => {
io.client.emit("message", "Connected to the server!");
});
}),
];
const worker = setupWorker(...handlers);
worker.start().then(() => {
// const ws = new WebSocket("ws://localhost:3000/socket.io/?EIO=4&transport=websocket");
const socket = io("ws://localhost:3000", {
retries: 1,
transports: ["websocket"],
port: 3000,
});
socket.connect();
});
export default function App() {
return <div></div>;
}