Created
August 14, 2020 06:20
-
-
Save Shramkoweb/dc98f721a1a2e78072a5dc68d7e8e708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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