• Post Reply Bookmark Topic Watch Topic
  • New Topic

starting RMI...

 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts!

Im developed a chat program based on socket connection, now I starting to convert the chat to a RMI based and I have some confusion. In the socket based I stored all the clients in a static Hashtable with the name of the client points to the clients PrintWriter and whenever I wanted to send massages to that a specific client I used to get his PrintWriter by Hashtable.get(�name�) and send him (println) massages.

Now in RMI I assume that all the connection information handled by the registry server , what if I want to refer to a particular client ,how can I do that?

Not so clear??? Here I demonstrate my problem:

here is the remote object


here is the server:


here is the client:



If I open 2 client and in the first client I logged in as �David� and in the second client I logged as �Shay� the second client shows �Shay� and �David� but the first shows only �David� how can I update the list in the first client??

This is the first time I mess my hands with RMI and my design is very poor I would like to hear comments about it and how to improve it.

Any kind of help will be greatly appreciate
Shay Gaghe

 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shay -
I apologize in advance for not reading your code, but I've already spent the majority of the day working on a PC -- a platform I would love not to have to use -- and I just can't tolerate MS's idea of a command line anymore.
In any event, you're really quite close. All you need to do is keep a collection of logged-on users. When that collection changes, you can send an event to each "LoginListener" and pass a revised version of the list.
Event messaging is a great way to learn about things before the fact. By updating the login data store, you prompt it to pass you back everything it currently has, and voila! you know who got there before you did.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you for the reply
As you said I kept references of the chatters to be able to refer to each of them by their listeners.
Shay Gaghe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!