October 11, 20188 yr Hi everyone, For some kind of mmorpg we are creating a new website. We have a chat interface in-game which is used by administration/moderation to communicate with each other while they are in-game issuing reports, searching for hackers/rulebreakers. While they are doing this, communication with other staff members is essential. The interface used in-game uses a small table in a SQL database. New messages are send to this table and a code in the script of the game displays the new message whenever a new message is send. We want to take this chat to the website. Because some administrators or moderators may not be available in-game, but on the website. They still require to communicate with eachother. Now before i start writing a page for this chat. I must tell that my knowledge does not go beyond PHP HTML and SQL. I was thinking that the chat would not be live on the website. The user would have to refresh the php page in order to read the new messages. I have been searching a while and came across AJAX. Can i show the info from the database live on the webpage using ajax? And if yes, how? Thanks in advance.
October 11, 20188 yr Or you just use one of the many propitiatory chats applications. There are loads of them. But they aren't that complicated to build and they often use AJAX or some other script for notifications.
October 11, 20188 yr Author 4 minutes ago, fisicx said: Or you just use one of the many propitiatory chats applications. There are loads of them. But they aren't that complicated to build and they often use AJAX or some other script for notifications. The thing with the propitiatory chats applications is that it might be hard to implant it so it runs with the same chat as it does in-game. Otherwise it would be useless.
October 11, 20188 yr Ajax is the wrong technology for real-time, it's still HTTP based so the connection closes once it has completed, so you need subsequent requests to check if new data exists, such as new messages, or total online users. There are ways around this, like long polling, which leaves the connection open until new data arrives, but it also sends down headers, cookie data, etc, which causes latency. It also has to establish a new HTTP handshake every time, which again, adds latency. I would look at websockets https://blog.teamtreehouse.com/an-introduction-to-websockets. Libraries like https://socket.io exist to help make this easier, and hosted services like https://pusher.com and https://pusher.com/chatkit are available if you don't want to handle the backend.
Create an account or sign in to comment