mirror of
https://github.com/kou029w/_.git
synced 2025-01-31 06:18:07 +00:00
Kohei Watanabe
5886ef9367
git-subtree-dir: socketio git-subtree-mainline:b755568571
git-subtree-split:ea8bce768f
19 lines
490 B
JavaScript
19 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));
|
|
});
|