mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
6be389ce29
Note: tests are not the only part of the codebase that uses `std`. Other parts, like `tools/`, do too. So, it could be argued that this is a little misleading. Either way, I'm doing this as discussed with @mmastrac.
20 lines
485 B
JavaScript
20 lines
485 B
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import { parse } from "../../../tests/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;
|
|
});
|