Link to home
Start Free TrialLog in
Avatar of mayhew
mayhew

asked on

Java chat

Hi everybody.

I've got a client that wants to add a chat room(s) to their site.

They don't just want a chat client that points to an mIRC server or anything like that.

It's just supposed to be chat functionality for the visitor's to their site.

Now chat rooms are not my strong point.

My understanding is that if I want to have a live chat (where you don't have to keep hitting refresh), you need to use Java (or ActiveX, but that's not a possibility since it needs to be a cross browser solution).

Question1: Is this understanding correct?

Second, my understanding is that if I use Java on the client, I will also need a Java chat server running on the web server.

The problem here is that most commercial hosting services (that I have checked with) will not allow server software to be installed.

Question2: Do I in fact need a Java chat server or is there another solution?

Any and all help/component referrals/host service referrals/comments will be most appreciated.

Thanks a lot!
Avatar of helver
helver

In general, if you want data to appear on the client browser without having to issue a request you want an applet.  However there are other solutions, although they aren't pretty.

1) Obviously, an applet.

2) Some sort of server push mechanism to force page updates down to the client.

3) Client pull... a timer that after X number of seconds, you go get the latest view of the pages.

These options are the result of http being a request/response protocol.  Options two and three work around that fact by sending multiple requests and/or receiving multiple responses.

You might be able to get away with dropping a link in that links you to an IRC type chat room - <a href="telnet://x.y.com:2900"> Chat here</a> or something of that nature.

If you had to choose between the three options listed above, I think that option 1 is preferable.  You get a little extra overhead for startup because you have download the applet, but once the applet is on the client machine, all you have to transfer are the messages.  Options two and three force an entire page to be sent with each update.
Avatar of mayhew

ASKER

helver, thanks for the comment.

That was pretty much my understanding on the client side.

What about on the server side (using the applet solution)?

Do I need a chat server?  Or can I just use applets that tie into a database?
In order to minimize traffic back and forth to clients, you should probably write some minimalist server...  I would imagine that the server would be event driven and would act something like:

while (1) {

   wait for event;

   switch (event type) {
   case NewClient:
      Add Client to ClientList;
      break;
   case ClientLogout:
      Remove Client from ClientList;
      break;
   case NewMessage:
      Send text to all Clients in ClientList;
      break
   }
}

No polling.  No tight loops.  It also doesn't have to be written in Java.  As long as you agree on a protocol it could be written in C, perl, C++, python, etc.  Writing it java would allow you to use RMI, however, and THAT would make it REALLY easy.
Avatar of mayhew

ASKER

Help me out.

What is RMI and how would it make things easier?

Also, do you know of any freeware software that may already exist?

And again, if I write (or use) server side software, won't I have to have it installed on the web server (which most services don't want to do)?  Or can I just have it run in my cgi-bin directory?

Thanks for your help.
Avatar of mayhew

ASKER

Can anybody help with this?
A client/server app would mean using the Server's JVM. If you
know of any free hosting servlet services, let me know ;P
I think your best solution would be to use an existing Chat server such as RajChat, they give the applet classes and html to install on your server:

Avatar of mayhew

ASKER

Thanks for your comment dale.

But in order to install that software on my web server, I need administrative rights.

And my hosting service won't install it for me.

Maybe the question here is if I need to bite the bullet and change to a different service?
ASKER CERTIFIED SOLUTION
Avatar of helver
helver

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No, my answer related to only installing the applet and html on your web service and that is all. the RajChat applet uses the existing RajChat Home server, i.e., java.KaushikRaj.com:8080, and not your own web server. Its a simple installation.
Avatar of mayhew

ASKER

dale,

As I suggested in my original statement, I can't have my clients going to a "shared" chat server.

It has to be available to my client's audience only.

"It's just supposed to be chat functionality for the visitor's to their site. "

Perhaps I didn't say it very well, but the intent was to have a service that only visitors to their site could access.

I have awarded the points to helver, but I realize that you may have misunderstood the question.  Therefore, if you have a solution that will help me, I will create another question for you.

But linking to someone else's chat server or installing chat server software will not answer my question.

Otherwise thanks for your comment.  I appreciate your effort.
Avatar of mayhew

ASKER

helver,

That is pretty much what I've decided.  I'm going to begin researcing a new service.

Can you point me in the right direction to begin studying RMI?  Books or sites?