Skip to content

Instantly share code, notes, and snippets.

@Shramkoweb
Created August 14, 2020 06:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shramkoweb/dc98f721a1a2e78072a5dc68d7e8e708 to your computer and use it in GitHub Desktop.
Save Shramkoweb/dc98f721a1a2e78072a5dc68d7e8e708 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
const cors = require('cors');
const socket = require('socket.io');
const port = 8888;
app.use(cors());
const chanels = new Map([
['rooms', []],
['messages', []],
]);
app.get('/', (req, res) => {
res.json([...chanels.values()])
})
const server = app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
const io = socket.listen(server);
io.on('connection', (socket) => {
console.log(socket)
socket.send('Hello!');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment