java RMI概念
我正在尝试实现一个简单的聊天应用程序,该应用程序通过中央服务器连接客户端与其他客户端,以便它们可以交换消息和文件。我还需要实现一个通知框架。例如,如果用户成功登录,或者他的好友登录,他会收到通知。 现在在 RMI 世界中这是如何实现的? 我正在考虑有一个远程对象“连接类”,客户端可以从中调用方法,例如“登录”,“断开连接”等...... 至于通知框架类,它们也必须是远程的吗?或者它们可以存在于服务器中吗? 谢谢
I am trying to implement a simple chat application that connects clients through a central server, with other client so they can exchange messages and files. I also need to implement a notification framework. for example, if a user signs successfully, or if a buddy of him signs in he get a notification.
Now in the RMI world how is this implemented?
I was thinking of having a remote object "connection class" that the clients call methods from it like "login in", "disconnect" etc...
And as for the notification framework classes do they have to be remote too? or can they lie in the server?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
远程系统之间的事件消息传递有点棘手。以下是必须发生的事情:
客户端必须注册对服务器端触发的事件的兴趣。要注册,客户端必须可远程访问事件源对象。
为了能够注册,客户端必须首先找到服务器,因此服务器对象必须可供客户端远程使用。
恶心吧?这就是用于实现远程事件处理的简单模式。
几周前,我开始了一个沿着这条路走下去的教程——它就在这里,我希望在本周末之前添加一些东西。唉,租金的需要已经受到干扰,我无法尽快增加租金。
然而,如果您等不及,那就是关键:双方都必须远程可用,消息系统才能正常工作。
该服务器和客户端必须是远程对象。
让所有客户端实现一个远程接口。
Event messaging between remote systems is a bit tricky. Here's what has to happen:
The client must register interest in the events fired on the server side. To register, the client must be remotely available to the event source object.
In order to be able the register, the client must find the server to begin with, so the server object must be remotely available to the client.
Ick, right? And that's the simple pattern for implementing remote event handling.
A few weeks ago I started a tutorial that was heade down this path -- it's right here, and I'm hoping to add something to it before the end of the week. Alas, the need to make the rent has interfered and I'm not able to add to it as quickly as I'd like.
If you can't wait, however, that's the key: both sides have to be remotely available for the messaging system to work.
that server as well as the client must be remote objects.
Let all clients implement a Remote interface.