Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.js:
- const express = require('express'),
- app = express(),
- http = require('http').createServer(app),
- io = require('socket.io')(http),
- port = process.env.PORT || 3020;
- require('./routes/v1/chat/chat')(io);
- chat.js:
- exports = module.exports = (io) => {
- io.sockets.on('connection', (socket) => {
- socket.on('room', (msg) => {
- socket.join(msg.roomId);
- });
- socket.on('message', (msg) => {
- console.log(msg)
- io.to(msg.roomId).emit('message', msg.message);
- });
- });
- }
Add Comment
Please, Sign In to add comment