-
Notifications
You must be signed in to change notification settings - Fork 6
Icon generation
When a new user connects, it receives an icon that is displayed to admins. On the back end, there is a list of strings e.g. "bear", "ox", "lion", etc that represent the icon. Each time a user connects and requests to chat, an icon is randomly picked from the list and associated with that user (specifically the user's socketio socket object). The icon is subsequently removed from the list. The icon is then sent to the admin front end along with the user waiting request.
On the front end, all the icons come from a sprite sheet /public/img/Animal Icons Small.png. The incoming icon string from the back end is assigned as an element id. The id is then styled in admin.css to pick the correct animal picture from the sprite sheet.
Upon user disconnect, the icon is reinserted back into the list so that it may be recycled. In the case where we run out of icons, a unique number is associated with the user as their 'icon'. Instead of an animal picture that gets displayed, the number is displayed in its place.