mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 22:30:02 -04:00
ws
This commit is contained in:
parent
4a12337f77
commit
48280d81ef
3 changed files with 47 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
import dotenv from "dotenv";
|
||||
import express from "express";
|
||||
import expressWs from "express-ws";
|
||||
import * as wrtc from "wrtc";
|
||||
|
||||
const configuration = {
|
||||
|
@ -66,7 +67,9 @@ async function connect(
|
|||
}
|
||||
}
|
||||
|
||||
const app = express();
|
||||
const app = express() as unknown as expressWs.Application;
|
||||
expressWs(app);
|
||||
|
||||
app.use(express.json());
|
||||
app.use((req, res, next) => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
|
@ -87,4 +90,11 @@ app.post("/connect", (req, res) => {
|
|||
}
|
||||
});
|
||||
|
||||
app.ws("/dev-ws", (ws, req) => {
|
||||
console.log("ws connect");
|
||||
ws.on("message", (msg) => {
|
||||
console.log({ msg });
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(3000, () => console.log("listening"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue