Jump to content

Creating Online Games w/ PHP


TheWandererLee

Recommended Posts

I am trying to get into creating online games with PHP but am having serious trouble. I've looked everywhere and can't seem to find the answer. All I want to be able to do for now is create a simple chat client using PHP and a combination of something else (preferrably flash). I've searched for a while and all I really seem to know is that I'm going to be doing either alot with socket connections, or MySQL databases, or both, but I'm really unsure at how to go about doing this. All I would like is a simple online chat system (that is real-time) please help :'(
-Lee
Link to comment
Share on other sites

I have made a semi real-time php chat room purely from PHP and mysql, but I don’t use it as I also made one from Java Which is very real time.lol. 
PHP / MySQL
--I would NOT recommend this method for large scale projects--
Have a framed window, Main frame contains chat room output text area, plus input text field and a button for saying stuff.  The second frame has a page refresh.  Mine had a refresh rate of 5 seconds (very unreal time).
This refreshing window holds the ID of the last message it got from the database.  Each time is refreshes it passes this ID to the server and only gets messages that are after this ID number.  So it never gets duplicate messages.  When the pages refreshes with the new message it uses JavaScript to pump the messages into the chat room output text area.  If you say something make a third unseen frame refresh with the data sent to the server to add to the database.  The next time your browser refreshes you will collect all new messages plus your own. The message will be in the right order, but will come in chunks (how ever many seconds you set the refresh rate).  Each time the server is hit by a message request, it deletes all messages that are 30 seconds old to save space on the server.  Since your refresh rate is only 5 seconds you won’t loss any messages.
Mine even had PVT facilities, so if you double clicked a name you opened a private window on either side of the conversation.    But, about 6 months ago my laptop failed and I lost all my work including two years worth of a website project, which included this chat room.    It was very basic though and I urge who ever wants to do one to do it as it isn’t as hard as you think.  And they are worthy contestants against real-time Java apps if you can’t afford or have the know how to get a Java one.

I also made one form Java which works extremely well (when tested with 2 people , lol)  haven’t had a chance to test it with more :(

So anyway, you CAN make a php chat room and they CAN be very good.  Just take the time to implement all the functionality that you would expect from a chat room and you can’t go wrong.
All the best, Graham Vincent
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.