• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

how do I know when client closes the browser ?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All
I am devloping the chat application.I have some problems with client logouts.I have used applet on client side and servlets on serverside.For actual communication UrlConnection class is used.
Each client calls the chatservlet ,if he did not have any messages that request will be kept in wait state.suppose when the client closes the browser,In the server side that request should be unblocked.
so how can i know in serverside that client closes the browser, so that i can notify other clients that so and so client logged out from chat application.

thank's
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if you can detect if an applet was closed on the server end however, I do believe that a SocketException is thrown on the server side. If you could just log the IP that created the exception and link it with the user, then you could probably find out. Either that or set a time out if they don't notify the server in x amount of seconds that they're still active. Not sure if you'd want that though.
 
Venkat Ammisetty
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai malik
With sockets it can be done,
but for my chat application Iam using URLConnection Object(The reason Iam using URLConnection object to work my chat application under firewall).But using this URLConnection object Iam calling the chat servelet which transferss the messages to the other clients who are in wating state.
In the chat servet I would like to know that which client logsout.
wating for u reply
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkat,
I think you can use Session Tracking Mechanism for your problem. When a user logs in create a session object and store it whereever you store user info. Now from each request we can trace the user session and do the needful.
Hope you got some idea from this.
Cheers
Binu

 
Saloon Keeper
Posts: 23884
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Considering the lamentable frequency with which browsers routinely die (or with Winodows, the entire OS), I fear you're never going to achieve complete happiness. However, when an applet is terminated, its stop() method is invoked - you could send a "Logging out" message from there.
Realize, however, that a browser is NOT a "telnet" session - users can flip back and forth between chat pages, open unrelated pages, open multiple chat pages, and do similar wierd things. http is stateless, so any sort of session you maintain is by convention, not enforced or supported by either browser or server. Or, in other words, you can try to manage things by adding the above to your client, but if the server is tracking users, it will require a timeout mechanism to catch the unannounced disconnects.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. I'm going to throw in my 2 cents worth (yeah. i know. not much is it...).
Even though I have not done this, I have read about it and I've wanted to try it out. But, supposedly, with RMI, you should be able to register an event with a listener bean on the server so that when the client bean logs out or the bean, otherwise, dies, it broadcasts an event that the server (listener) bean receives and knows to do...whatever...clean up, etc. And now we're beginning to get to the fringes of EJB's.

Originally posted by Venkat Ammisetty:

Hi All
I am devloping the chat application.I have some problems with client logouts.I have used applet on client side and servlets on serverside.For actual communication UrlConnection class is used.
Each client calls the chatservlet ,if he did not have any messages that request will be kept in wait state.suppose when the client closes the browser,In the server side that request should be unblocked.
so how can i know in serverside that client closes the browser, so that i can notify other clients that so and so client logged out from chat application.

thank's


 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic