• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session etc. inside a socket server  RSS feed

 
Jean-Michel Vilain
Greenhorn
Posts: 27
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm building a kind of battle.net, using Flash for the client and Java for the server side. Data is exchanged in both ways via sockets. I really need sockets because the server has to tell the clients when certain events happen (like a chat message or so).
Problem is I have no idea how to maintain a "session". I don't even see how a button like "keep me logged in for the whole day" would work. This isn't a HTTP servlet.
Is there an API or a framework of some kind, made for socket server, to provide me with a session class, and stuffs like a basic user profile class to be inherited? Or do you think I'd better code all that from scratch?
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make your state saving class serializable and save it to disk with a name you can compute from the user's name.

Thats what I do with the user state in my on-line exams. Serialization is surprisingly fast and that way you can save whatever you like. Hint - use a HashMap to save named variables for real flexibility.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!