Question: index.js var app = require( 'express' )(); var http = require( 'http' ).Server(app); var io = require( 'socket.io' )(http); app.get( '/' , function (req, res){
index.js
var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); }); Project Description:
This project is based on an open source Node.js application posted at: http://socket.io/get-started/chat/. Your job is to modify the index.js page so that the app will have two new features:
Whenever someone joins or leaves the room, a message will be displayed to all users.
Instead of having a username, each user is assigned a socket generated session id when he/she first joins. See the screenshots below.

When a user joins the chat room, you need to register the connect event. For example:
io.on(connect, function(socket)) {
io.emit(chat message, --- someone just joined the room!!!);
});
When a user leaves the chat room, you need to register the disconnect event on that particular socket. For example:
io.on(connection, function(socket) {
socket.on(disconnect, function() {
io.emit(chat message, --- someone just left the room!!!);
});
});
To get the session Id from each user, you can use socket.client.id property. For example:
io.emit(chat message, --- + socket.client.id + just joined the room!!!);
You only need to submit the modified index.js file.
Question 1: What third-party modules does this project use? What are they? What are their versions? How did you find that information?
Question 2: Who are the contributors for socket.io module? List their names and email addresses.
Question 3: What do you need to do if the event name chat message is changed to trump in index.html file so that the application doesnt break?
var socket = io();
$('form').submit(function(){
socket.emit('trump', $('#m').val());
$('#m').val('');
return false;
});
socket.on('trump', function(msg){
$('#messages').append($('
});
pls send me ans as soon as possible.
D Socket.IO chat
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
