RMI chat - callbacks.
843793Feb 23 2006 — edited Mar 12 2006hi,
i am currently creating a chat system (yet another one, my apologies) usign RMI
First i set it up a server.
------------------------------------------------------------------
public class Server {
private static final String HOST = "localhost";
public static void main(String[] args) throws Exception {
//Creates an instance of my DbHandler class
//for binding.
DbHandler dbHandler = new DbHandler();
try {
LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
}
catch (RemoteException e) {
System.err.println(e);
System.out.println("Server:RegistryFailed");}
//Binds the RMI objects
String rmiObject = "rmi://" + HOST + "/RemoteObjects";
Naming.rebind(rmiObject, dbHandler);
System.out.println("Binding Complete...\n");}
}
-------------------------------------------------------------------
i sent messages from the clients to the server and they are echoes back out to the command line on the server. Everything so far so good.
The next step was to allow this server to echo any messages sent to it back to the client. I added most of the above(all but the registry start) to the client.java (FrameChat.java) and changed /RemoteObjects to /RmoteObejctServer.
When i load up the first instance of the chat room, its fine the server echos back the message, all seems correct. But when i load up another instance of the chat room, the server although still receving messages from multiple sources, it only echos back the messages to the most recently created instance of the chat room.
i assumed the server would send out the function name and all instances would identify they have that method and therefore run the method, but the server only seems to connect to the most recent method.
there are 8 java file one of the being the login files uses RMI and odbc, i have uploaded the files to the following location if anyone would be able to help me out in this puzzling topic.
http://homepage.eircom.net/~cartydsl/Java/java.html
cheers and thank you for any help! I am probably unclear about alot if ayone can help please ask me more and i will hopfully be able to answer.
cheers,
ronan