• Post Reply Bookmark Topic Watch Topic
  • New Topic

rmi chat

 
venkataraman bagavathisub
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
What would be the best way for the RMI server to uniquely
identify each client that logs on to it,(in addition to a user
name)? how can i connect two machines in two proxy environments(physically not connected)?how will my machine identify the other machine(since ip addreses of proxies need not be unique>).
please help me on this. i am developing a multiuser chat program.
thank you
------------------
 
Jerry Pulley
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkataraman,
You've got two choices; it depends on whether you want the unique per-client identifier held on the client or server side. (It's got to go somewhere; those are the only choices.)
If your remote clients all receive the same remote reference to your server class (that is, if you don't create any 1-per-client server-side objects), then you'll want to give each client instance a unique identifier that they pass to the server as a parameter in every remote method call. java.rmi.server.UID works well for this approach. You'll have to generate the UID on the server when the client first connects. You shouldn't generate it on the client for two reasons: 1) security, and 2) UID is only guaranteed unique with respect to the host its generated on.
If your server design uses a per-client proxy class, then identifying unique clients is easy. You use the proxy object itself as the identifier.
Jerry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!