Writing a Chatroom anyone?
I've decided it's probably time to write a chatroom for my website (and to learn how these work). I know PHP (and ofcourse Java). My webhoster doesn't allow Servlets, else it'd be easy. I don't want to use META refresh tags to do it, that would be a pain the the ***. How would I do this? How would I organize the sockets?
Just some general ideas/tips would be helpful.
[387 byte] By [
Vagabona] at [2007-11-27 6:38:27]

> How would I organize the
> sockets?
>
> Just some general ideas/tips would be helpful.
In the US, sockets are placed in junction boxes which are routinely attached to wall studs (2 X 4) with rectangular cutouts in the drywall where wall plates are used to cover the wires and plug.
Google is your friend.
> > How would I organize the
> > sockets?
> >
> > Just some general ideas/tips would be helpful.
>
> In the US, sockets are placed in junction boxes which
> are routinely attached to wall studs (2 X 4) with
> rectangular cutouts in the drywall where wall plates
> are used to cover the wires and plug.
Needs work.
> I've decided it's probably time to write a chatroom
> for my website (and to learn how these work). I know
> PHP (and ofcourse Java). My webhoster doesn't allow
> Servlets, else it'd be easy. I don't want to use META
> refresh tags to do it, that would be a pain the the
> ***. How would I do this? How would I organize the
> sockets?
>
You are going to use applets and HttpURLConnection to a web service written in PHP.
So...
User types in Applet -> Applet posts content to Web service -> You do something in PHP
Applet (every so often) -> applet sends request for latest content to web service -> You send back data as XML from PHP -> Applet reads XML and gets latest content and displays
I did google, but it didn't help much. I found a bunch of stuff for Servlets and php based meta refresh. I'll dig deeper.
Eveything I look at for Java says I need a Servlet to organize the connections for the client side applets.
> Eveything I look at for Java says I need a Servlet to
> organize the connections for the client side applets.
Yes. But not every Servlet is a Java Servlet.
You need a servlet in the sense of "some code that runs on the web server" This could be a Java Servlet, ASP, PHP, Perl, ColdFusion, etc.
The webhoster is a piece of ****, it supports MySQL and PHP, how can I use php for this? I don't really want to use the META refresh tags,a nd I have no idea how to manage sockets with PHP.
> The webhoster is a piece of ****, it supports MySQL
> and PHP, how can I use php for this? I don't really
> want to use the META refresh tags,a nd I have no idea
> how to manage sockets with PHP.
Okay please READ over my previous posts.
Your client side will consist of an applet.
The applet will use HttpURLConnection to connect to your web page (done in PHP).
Your PHP will output XML.
The applet will parse the XML and get the content.
The applet will display it.
No META tags, and I never mentioned them. And no direct sockets in PHP either, I never mentioned them either. So please don't mention them again, they aren't needed and you are worrying about things you don't have to worry about.
How is it going to get the new data? PHP is a one time thing, it does it's thing when it loads from the server, once the client has it, it doesn't do anything more.
Nevermind, I see, have the applet on one page, the the PHP stuff on another and have the applet reload the other page and get the XML, right?
> Nevermind, I see, have the applet on one page, the> the PHP stuff on another and have the applet reload> the other page and get the XML, right?Yes.
I've written a chatbox with Java Enterprise Beans but i would i to know how to make it into an apply form also so i can create an applet that connects to my current chatserver D
How would I organize what the people say? If I try to use a flat file I'll run into problems with it being used and stuff like that (syncronising the File wouldn't help between more than one applet), if I use a database I could easy beat it to death if the chatroom got busy.
humm...
Thinking aloud, applet sends data to another php page that appends the text and user (combined into an object) on to another object that holds the data. The XML page gets the data from that object. How could that object exist between the two...
Note: only heard of Ajax, never used it.