mirror of
https://github.com/denoland/deno.git
synced 2024-11-23 15:16:54 -05:00
89160e7cd8
This reverts commit
17d1c7e444
.
The `Deno.serve` signature update in
https://github.com/denoland/deno/pull/18759 broke the testee server
right after this patch landed on `main`.
20 lines
484 B
JavaScript
20 lines
484 B
JavaScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
import { parse } from "../../../test_util/std/flags/mod.ts";
|
|
|
|
const { port } = parse(Deno.args, {
|
|
number: ["port"],
|
|
default: {
|
|
port: 6969,
|
|
},
|
|
});
|
|
|
|
const { serve } = Deno;
|
|
|
|
// A message-based WebSocket echo server.
|
|
serve({ port }, (request) => {
|
|
const { socket, response } = Deno.upgradeWebSocket(request);
|
|
socket.onmessage = (event) => {
|
|
socket.send(event.data);
|
|
};
|
|
return response;
|
|
});
|