Jump to content

Archived

This topic is now archived and is closed to further replies.

jwk811

live chat/chatrooms

Recommended Posts

in a person to person chat room if you're using php you would need to keep reloading the page right? to make it so you dont have to load it can you use javascript? if so how would i do that.. and how exactly does the person to person chat work.. i have an idea.. well its actually pretty confusing.. would i need to be using asp, whatever that is?

Share this post


Link to post
Share on other sites
ASP is simply another server side scripting language (Microsoft's, actually) like ASP. In theory, a PHP chatroom would have to reload the page every few seconds to show you the new posts. However, if you use AJAX (client side HTTP requests), you could pull the newest posts every few seconds and simply tack it on to the tail of the chat content. That would be your best bet if you're wanting to use PHP for one.

Share this post


Link to post
Share on other sites
when someone sends a message when they click send will it have to go to a script to get transfered over? and then redirected back to the page? how would that work?

Share this post


Link to post
Share on other sites
[quote author=jwk811 link=topic=112840.msg458192#msg458192 date=1161888845]
when someone sends a message when they click send will it have to go to a script to get transfered over? and then redirected back to the page? how would that work?
[/quote]

Basically, you want a table that will hold the conversation. When someone hits "send", you'll want to send their entry to append to the end of the record. Of course, since they're the one sending the message, you can immediately display it on their screen with javascript. Then, you also want to have an HTTP request running to the server to grab any posts since the last request (usually somewhere around the ballpark of 8-12 seconds is a good gauge). If there are new entries, retrieve them via the HTTP request and update the display accordingly. Otherwise, it's the exact same logic behind every chatroom you've ever visited.

Hope this helps.

Share this post


Link to post
Share on other sites
thanks.. how can i use a HTTP request to catch the posts? its like this right? a chater sends a message and it appears on their screen on the bottom of the record and then the other chater must catch that post with the HTTP request and then display it onto their record that way? would i need to send the message through a script so i could get it into a variable?

Share this post


Link to post
Share on other sites
jwk, you're going to need at least a basic knowledge and understanding of JavaScript and the XMLHttpRequest element to make an AJAX chat. I am working on a flat-file based Ajax chat [url=http://ryan.crawford.com]here[/url] (second link from the bottom on that page).

What I did was initiate the request element every time the form was submitted or enter key pressed. The request sent the line of chat to a PHP script which writes it too a flat file, while a different request element checks the flat file for changes. If a change happened, a line difference calculation occurs and PHP returns all lines submitted since the last change.

If you want to circumvent the AJAX process, just split a page into two frames. In one frame, make a page that auto or meta-refreshes at a set interval, and in the other frame, create a basic form that posts information to a database whose action property is itself. Thats about as basic as PHP applications get.

Share this post


Link to post
Share on other sites

×

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.