summaryrefslogtreecommitdiff
path: root/ext/websocket/autobahn/autobahn_server.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/websocket/autobahn/autobahn_server.js')
-rw-r--r--ext/websocket/autobahn/autobahn_server.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/websocket/autobahn/autobahn_server.js b/ext/websocket/autobahn/autobahn_server.js
new file mode 100644
index 000000000..c678dfc1a
--- /dev/null
+++ b/ext/websocket/autobahn/autobahn_server.js
@@ -0,0 +1,20 @@
+// 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((request) => {
+ const { socket, response } = Deno.upgradeWebSocket(request);
+ socket.onmessage = (event) => {
+ socket.send(event.data);
+ };
+ return response;
+}, { port });