const add_user = (socket, username, usernames, rooms) => {

	//console.log(`adduser: ${username}, ${usernames[username]}`);

	// store the username in the socket session for this client
	socket.username = username;
	// store the room name in the socket session for this client
	socket.room = 'room1';
	// add the client's username to the global list
	usernames[username] = username;
	// send client to room 1
	socket.join('room1');
	// echo to client they've connected
	socket.emit('updatemsg', 'SERVER', 'you have connected to room1');
	// echo to room 1 that a person has connected to their room
	socket.broadcast.to('room1').emit('updatemsg', 'SERVER', username + ' has connected to this room');
	socket.emit('updaterooms', rooms);
};

module.exports = add_user;

