Am after some help with a chat application I am building. Basically I am having real problems with showing a list of all the users currently logged in. Currently I have a bean for each user that is then also added to an application session bean which shows all the users, I have run into big problems though trying to remove a user from this application session bean should a user just close their browser so I think I'm going back to the drawing board.
What is the best way for coding this ? I was thinking maybe, use a servlet to 'log' a user in, create a bean for them and then add that bean to a bean containing a list of all the users, I could then use the session listener to keep check of when a user disconnects and the remove that user from the list of logged on users ? Would the bean containing the list of users be available for all the users to see ?
I'm sure this must of been done before and I've searched and searched but I'm really looking for a definitive guide as to how I should approach this whole thing before I jump in and start trying to code it all again.
Any ideas or input very gratefully received.
Are you using an HTML based client? You really need a client with state. I wrote a Flash based client that communicates with a Java chat server. The server keeps up with who's connected by sending out pings to the clients. If the client doesn't pong back, it's dropped. I'm sure you could write a Java client that does the same thing. An HTML based client won't be able to do this, without some horrible refresh hack.
Joined: Oct 11, 2002
Not sure how that would react to clients behind firewalls though ? I've sort of now kludged something together using Applets on the browser and then calling the destroy method which in turn calls a servlet on the server removing the client from the list of logged on users. Difficult work though then trying to design a site around an applet that mustn't be closed I'm sure there are easier ways but I have yet to see a simple and concise explanation. Cheers Jon
Joined: Jun 14, 2002
Yeah, I don't think the client side destroy can be depended on. What happpens when the client's machine crashes or is unplugged? As for firewalls, those ports are firewalled for a reason. So if the chat clients doesn't work, the sysadmin doesn't want people chatting. I know AIM steps around this and uses port 80, which pisses most sysadmins off.
Joined: Oct 11, 2002
As for firewalls, those ports are firewalled for a reason. So if the chat clients doesn't work, the sysadmin doesn't want people chatting.
I am creating a web application using JSP and Servlets which enables users to chat using JMS. I need to know how to know the solution to the following situation:
user1 and user2 are chatting with each other.
when user1 sends a message to user2 I use JMSQueue to insert the message at the server end.
But user2 retrieves the message from the queue only when I manually refresh the page or set the page to an autorefresh using a timer.
Please suggest how to overcome this drawback ie. how can I retrieve the message at the client end which is user2 only when the user1 submits the message ?