mirror of
https://github.com/kou029w/_.git
synced 2025-01-31 06:18:07 +00:00
20 lines
490 B
JavaScript
20 lines
490 B
JavaScript
|
// @ts-check
|
||
|
const path = require("path");
|
||
|
const app = require("express")();
|
||
|
const http = require("http").createServer(app);
|
||
|
const io = require("socket.io")(http);
|
||
|
|
||
|
const port = Number(process.env.PORT) || 8080;
|
||
|
|
||
|
app.get("/", function(_, res) {
|
||
|
res.sendFile(path.join(__dirname, "public", "index.html"));
|
||
|
});
|
||
|
|
||
|
http.listen(port, function() {
|
||
|
console.log(`listening on http://localhost:${port}`);
|
||
|
});
|
||
|
|
||
|
io.on("connect", socket => {
|
||
|
socket.on("message", message => io.send(message));
|
||
|
});
|