mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 14:20:01 -04:00
ws
This commit is contained in:
parent
4a12337f77
commit
48280d81ef
3 changed files with 47 additions and 2 deletions
|
@ -15,12 +15,14 @@
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"esbuild": "0.19.0",
|
"esbuild": "0.19.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"express-ws": "^5.0.2",
|
||||||
"firebase": "^10.1.0",
|
"firebase": "^10.1.0",
|
||||||
"preact": "^10.16.0",
|
"preact": "^10.16.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"wrtc": "^0.4.7"
|
"wrtc": "^0.4.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^4.17.17"
|
"@types/express": "^4.17.17",
|
||||||
|
"@types/express-ws": "^3.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
pnpm-lock.yaml
generated
33
pnpm-lock.yaml
generated
|
@ -17,6 +17,9 @@ dependencies:
|
||||||
express:
|
express:
|
||||||
specifier: ^4.18.2
|
specifier: ^4.18.2
|
||||||
version: 4.18.2
|
version: 4.18.2
|
||||||
|
express-ws:
|
||||||
|
specifier: ^5.0.2
|
||||||
|
version: 5.0.2(express@4.18.2)
|
||||||
firebase:
|
firebase:
|
||||||
specifier: ^10.1.0
|
specifier: ^10.1.0
|
||||||
version: 10.1.0(react-native@0.72.3)
|
version: 10.1.0(react-native@0.72.3)
|
||||||
|
@ -34,6 +37,9 @@ devDependencies:
|
||||||
'@types/express':
|
'@types/express':
|
||||||
specifier: ^4.17.17
|
specifier: ^4.17.17
|
||||||
version: 4.17.17
|
version: 4.17.17
|
||||||
|
'@types/express-ws':
|
||||||
|
specifier: ^3.0.1
|
||||||
|
version: 3.0.1
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
@ -2618,6 +2624,14 @@ packages:
|
||||||
'@types/send': 0.17.1
|
'@types/send': 0.17.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@types/express-ws@3.0.1:
|
||||||
|
resolution: {integrity: sha512-VguRXzcpPBF0IggIGpUoM65cZJDfMQxoc6dKoCz1yLzcwcXW7ft60yhq3ygKhyEhEIQFtLrWjyz4AJ1qjmzCFw==}
|
||||||
|
dependencies:
|
||||||
|
'@types/express': 4.17.17
|
||||||
|
'@types/express-serve-static-core': 4.17.35
|
||||||
|
'@types/ws': 8.5.5
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/express@4.17.17:
|
/@types/express@4.17.17:
|
||||||
resolution: {integrity: sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==}
|
resolution: {integrity: sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -2689,6 +2703,12 @@ packages:
|
||||||
resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==}
|
resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/ws@8.5.5:
|
||||||
|
resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==}
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 20.4.9
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/yargs-parser@21.0.0:
|
/@types/yargs-parser@21.0.0:
|
||||||
resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==}
|
resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -3536,6 +3556,19 @@ packages:
|
||||||
strip-final-newline: 2.0.0
|
strip-final-newline: 2.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/express-ws@5.0.2(express@4.18.2):
|
||||||
|
resolution: {integrity: sha512-0uvmuk61O9HXgLhGl3QhNSEtRsQevtmbL94/eILaliEADZBHZOQUAiHFrGPrgsjikohyrmSG5g+sCfASTt0lkQ==}
|
||||||
|
engines: {node: '>=4.5.0'}
|
||||||
|
peerDependencies:
|
||||||
|
express: ^4.0.0 || ^5.0.0-alpha.1
|
||||||
|
dependencies:
|
||||||
|
express: 4.18.2
|
||||||
|
ws: 7.5.9
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- bufferutil
|
||||||
|
- utf-8-validate
|
||||||
|
dev: false
|
||||||
|
|
||||||
/express@4.18.2:
|
/express@4.18.2:
|
||||||
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
|
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
|
||||||
engines: {node: '>= 0.10.0'}
|
engines: {node: '>= 0.10.0'}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
import expressWs from "express-ws";
|
||||||
import * as wrtc from "wrtc";
|
import * as wrtc from "wrtc";
|
||||||
|
|
||||||
const configuration = {
|
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(express.json());
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
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"));
|
app.listen(3000, () => console.log("listening"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue