aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/websocket-subprocess.ts
blob: cf64f18ef2fe6f14b491b892bbc4e77d921d1a95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
const host = process.argv[2];

const ws = new WebSocket(host);

ws.onmessage = (message) => {
  if (message.data === "hello websocket") {
    ws.send("hello");
  } else if (message.data === "timeout") {
    setTimeout(() => {
      ws.send("close");
    }, 300);
  }
};