开发者

Java rmi, differentiating between multiple client

Edit: To be clearer, I basically need to differentiate between the different clients doing remote method invocation in objects stored in the server remote object registry. How could I do that?

And here is the situation:

I am currently in the process of creating a client/server command line interface application using Java rmi to exchange data (stored in Strings) between the clients and server.

I'm hav开发者_JAVA百科ing problem whereas I must allow a client to send an authentication command with a user/pass. This authentication command (exemple: >user myUserName myPassword) must be sent through the same remotely called method used to send all the other commands for which the server must answer.

My problem : The client must, strictly, only send his commands and display the text result of his command received from the server. As simple a client as it gets, it has no state.

Since some methods requires the client to be logged in or have a different server-side implementation if the client is logged in or not, I need to to keep track of the client logged in state on the server(not a problem, I plan to simply keep a time stamp on each user in the user database and use a timeout) and must also differentiate between different clients.

Now, I think I have a good idea of how remote object works and I've been able to register a remote object on the server side and access a remote method from it using the client.

So, I need to do more, I must not only have client being able to access remote method, I also need the remote method(and the server running them) to know which network client is invoking this method(without passing the client username/pass as parameters in the remote method).

I think the rmiclientsocketfactory and rmiserversocketfactory must be customly used to do this, but I don't know how to proceed.

thanks you all for your time.


Objects are not stored in the registry. Stubs are stored in the registry. The remote objects are in the server host.

See java.rmi.server.RemoteServer.getClientHost().

Socket factories haven nothing to do with it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜