add channel communication
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { forgetConnection, processMessage } from "./websocket-handler";
|
||||
|
||||
import Path from "path";
|
||||
import { ServerWebSocket } from "bun";
|
||||
|
||||
// CONFIG
|
||||
const staticDir = "static/dist";
|
||||
const defaultPage = "index.html";
|
||||
const errorPage = "404.html";
|
||||
|
||||
// TYPES
|
||||
export type WS = ServerWebSocket<unknown>;
|
||||
|
||||
// SERVER
|
||||
const server = Bun.serve({
|
||||
fetch(request, server) {
|
||||
@@ -27,9 +33,11 @@ const server = Bun.serve({
|
||||
|
||||
websocket: {
|
||||
message(ws, message) {
|
||||
|
||||
processMessage(ws, message.toString());
|
||||
},
|
||||
close(ws, code, reason) {
|
||||
forgetConnection(ws);
|
||||
},
|
||||
close(ws, code, reason) {},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user