instead of using appendP for 'CHAT' 'REGISTER', call the new display-text-message function to append a new message, passing it the params (username and message)
Register a different handler for app 'CHAT' and method 'REGISTER', the handler should be called 'updateUsers'.
Also register a handler for app 'CHAT' and method 'DISCONNECT', also calling the same 'updateUsers' handler (perhaps build this function and add it to the helper directory)
This function will be called with two arguments, 'sender' and 'users'
(sender will be 'server')
(users will be an array of objects, in the following form; [{username: 'john', permissions: ['av', 'chat']}...])...
Inside this function, for each user object, check whether the user has chat and av permissions.
If they do have both permissions, and there are no \
elements inside of the \
element (I.e no Mentors), append a new \
element to this \
, with the username as the text, and a class of 'online__user'
else if they do have both permissions, but there is already a \
Chat.js updates
We need the following updates to our chat.js;
element (I.e no Mentors), append a new \- element to this \
- else if they do have both permissions, but there is already a \
- element in the mentor
, with the username as the text, and a class of 'online__user'
, add a \- to the moderator \
- else if they only have chat permissions, add a \
- element to the student \
.