Conversation
server.js
Outdated
| var client = new Client(socket); | ||
| pool.push(Client); | ||
|
|
||
| socket.on('data', (socket) => { |
There was a problem hiding this comment.
you are passing in socket here to this function. This is actually the data part so the better word to use would be data. It is also erring out on the next line when you try to access data.
server.js
Outdated
|
|
||
| ee.on('@all', (client, string) => { | ||
| pool.forEach((c) => { | ||
| c.socket.write(`${client.nickname}: ${message}`); |
There was a problem hiding this comment.
what is message here? do you mean string?
There was a problem hiding this comment.
message is changed from message to string. I did this because we didnt set the string to a var like message like we did the block up.
model/client.js
Outdated
| 'use strict'; | ||
|
|
||
| const uuidv4 = require('uuid-v4'); | ||
| const Client = module.exports = (socket) => { |
There was a problem hiding this comment.
This is throwing an error that Client is not a constructor. I was able to fix it by changing it back to the pattern used in class by Brian. Switch it back to the word function to get this to work.
There was a problem hiding this comment.
Changed from fat arrow to normal function declaration because when using 'this.' with fat arrow it is just taking everything from the scope. So we do a normal function declaration because it will pass whatever is filled into the arguments.
server.js
Outdated
| }); | ||
|
|
||
| server.on('connection', (socket) => { | ||
| var client = new Client(data); |
There was a problem hiding this comment.
The sockets that I meant needed to be changed here is the one in the socket .on('data', (socket) => { below. Sorry if I messed up this comment. The cient(socket) to the client I believe is fine but when you call data.toString() on 41 it broke.
server.js
Outdated
| pool.forEach((c) => { | ||
| if(client.nickname === client.nickname){ | ||
| pool.splice(i); | ||
| }; |
There was a problem hiding this comment.
You are missing a closing }) here. It looks correct right now because the indentation on the if block is shifted one over but it breaks your server file.
No description provided.