Open jetrotal opened 2 years ago
Looks really good, thanks! However, it may be a little ahead of the project. Right now, there's actually no differentiation between messages and "connected to..." alerts. The client also doesn't tell if a chat message comes from itself or another player. And you can only set your name once.
Also, I found a bug: if you send some messages, then scroll up, then send another message, it will scroll to the bottom. I don't think that's good, because it could prevent people from comfortably reading older messages.
maybe, the differentiation can be made by sending strings formatted as JSON, like:
var incomingMSG = `{
"message": {
"source": "Server",
"type": "alert",
"user": "warning",
"content": "Connected to Room 3"
}
}`
then the js side of it could parse the message string as an object.
I'll check later the scrolling issue Fixed the chat scroll bug!
Hey! I've been testing writing stuff in CSS and JS that could be used on the Player's page UI:
https://codepen.io/jetrotau/full/ZEJqmEE It already has functions related to the client side of the chat, like:
Display Alerts:
Display Chat Messages from Client:
Display Chat Messages from Other Players:
Clear Chat Button + Info Button + Alerts![image](https://user-images.githubusercontent.com/45118493/142086966-4ac38bf1-754d-45ef-9571-b7d9d8920066.png)
Hide Chat Button:![image](https://user-images.githubusercontent.com/45118493/142086826-1b9a287d-8497-42e6-b44a-9f305ff313f5.png)
You can also customize the colors scheme of it:![image](https://user-images.githubusercontent.com/45118493/141891052-e1582f1c-f24a-49c3-be8d-51ee6aeed2fd.png)
I didn't want to make a mess in your code, so hosted it on codepen: https://codepen.io/jetrotau/full/ZEJqmEE But I tried to keep the names of the HTML elements and some variables that I saw on the current Play page.
feel free to use or discard any of the ideas from it.