Use RMI to write a real-time chat program RMI

Source: Internet
Author: User

(Remote method call) for JavaProgramWriting real-time chat provides a good solution.
1. userinfo object: including: User ID, user name, client object (chatter) pointer. This object is created on the client. When it is connected to the server, it is sent to the service to save online user information. If it is disconnected from the server, this object will be deleted from the server online user list.
2. chatter object: This object is a client in the RMI model. But in fact, a server can call the remote method of the server to communicate with the server, the server can also use this method to communicate with the client.
3. server Object: This object is a server in the RMI model. when the client is connected to or disconnected from the server, the methods login (userinfo) and logout (userinfo) of this object are called respectively) to tell the server that a user has logged on or exited. When a client communicates with another client, send (userinfo from, userinfo to, string mess) is called to send information.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.