In: Computer Science
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 doesn’t break?
var socket = io();
$('form').submit(function(){
socket.emit('trump', $('#m').val());
$('#m').val('');
return false;
});
socket.on('trump', function(msg){
$('#messages').append($('<li>').text(msg));
});
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'); });
Ans 1) The app uses the following third party modules-
(i) socket.io - It is a library which enables the flow of communication between a server and browser. Browser can send, receive the information to and from the server. For instance the chat applications in node.js uses the socket.io module.
The version can be found from the package.json file in the project that will be like socket.io-3.0 or if there is no package.json file present you can directly open the official website of library and fing out the latest version.
It is being imported in your index.js file at line number 3.
(ii) express - It is a framework used for the the for building robust application in node.js. It provides a wide range of functionalities and API's to ease your application building process. For e.g you have used http which is API given by express.
The version can be found from the package.json file in the project that will be like express-2.3 or if there is no package.json file present you can directly open the official website of library and fing out the latest version.
It is being imported in your index.js file at line number 1.
Ans 2) Socket.io is built by Auttomattic Inc. The main author of socket.io is Guillermo Rauch.
Names of the community behind Socet.io. ( However their email addresses are not public,so i am giving you their linked in profiles)
Guillermo Rauch (Linked in- https://www.linkedin.com/in/guillermo-rauch-b834b917b/)
Arnout Kazemier (Linked in - https://www.linkedin.com/in/arnoutkazemier/?originalSubdomain=nl)
Jay Borenstein (Linked in - https://www.linkedin.com/in/jayborenstein/)
Ans 3) If you change the event name from chat message to trump in your html file then you can also edit your index.js file by replacing the socket.on('chat message' with socket.on('trump'.