Create socket connection and send a message
This commit is contained in:
@@ -7,6 +7,12 @@ app.get('/hello', function (req, res) {
|
||||
res.send('Hello World!')
|
||||
})
|
||||
|
||||
app.listen(3000, function () {
|
||||
const server = app.listen(3000, function () {
|
||||
console.log('Example app listening on port 3000!')
|
||||
})
|
||||
|
||||
const io = require('socket.io').listen(server);
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
socket.emit('message', 'hello socket');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user