Aliza tcp#8
Conversation
| const clients = []; | ||
|
|
||
| module.exports = exports = net.createServer((socket) => { | ||
| socket.name = socket.remotePort; |
There was a problem hiding this comment.
When you add your own property to an instance you could run into a problem if the instance already has a property using that name. You could check docs, use a test in code (!socket.name) to be sure its not used, or assign a more app specific name like myapp_name. In this code you probably don't need to save it because you're using the value of a property that already exists. Wherever you're test or outputting socket.name, you could just use socket.remotePort. If you wanted to maintain a really app specific name, your sockets array could contain an array of objects, each of which holding the socket and the unique name like sockets = [{socket: , name:"Fred"}];. That all said, your stretch to supply a user id works!
No description provided.