0

I am looking for working example of chat application using glassfish and comet. I expect that when one client will update data in server , the other clients will also see the data witout refreshing the page. Or any push notification that the data in the server has changed. Its very urgent. Thanks in advance

App Work
  • 21,899
  • 5
  • 25
  • 38
  • This is not a question, what have you tried? did you get an exception? are you expecting us to write the code for you? – Tomer Jul 22 '12 at 08:13
  • I am trying this http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-comet-hidden/1.7.3.1/ , but it seems it does not update the 3rdparty client about the data change in the client. Say for instance i have opened 2 clients , and in one client i clicked the button , the counter does not update in the another client unless i refresh. Any Way, Thanks for your promt response. – App Work Jul 22 '12 at 08:16
  • Please rephrase your question, post some relevant code snippets and describe the problem properly. – Tomer Jul 22 '12 at 08:18

2 Answers2

1

Instead of Commet , Just use Socket . You need feel the pulse of the server continually for getting update from other users's responses . In the response token sent from the server , if there is new update, pull the updates in a new thread. The messages can have a header which contains the sender device identity and the message body. So at a certain point in time, you can pull all the updates for your devices and the user interface can show them respectively in each view; In the list view of the users, show the last message + the number of the new unread messages. In the chat window, show all the messages. that belongs to the user.

Hope it helps

Amar boi
  • 90
  • 5
0

The easiest way to build a web-based chatroom is to use a comet cloud service rather than build long polling stuff by yourself. You can see an example from EZComet

enter link description here

Though, it is in PHP, but I think it would be easy to write a Java version.

Fang-Pen Lin
  • 13,420
  • 15
  • 66
  • 96