JSP, Java, and Ajax text chat room design ideas

Source: Internet
Author: User

JSP,Java,AjaxText Chat Room Design Ideas

 

Text Chat rooms can be used as a platform for topic discussion or an online conference room, improving the communication means of the OA system.ShufeiOAUsing J2EE technology, developers use JSP, Java, and Ajax technology to implement text chat rooms.

The basic function of a chat room is that multiple people are online at the same time. After one person sends a message, other online users can see the message. Here we need to solve two main problems: how to update online staff and how to update messages. Two global variables are used to store online staff information and messages. Between application and static, we chose static. Therefore, two maps, onlinemap and messagemap are defined.

Update onlinemap when logging on to the chat room. At the same time, start the Javascript timer on the page to dynamically detect changes in onlinemap and messagemap. Once there is an update, JavaScript automatically obtains the updated content, parses it, and updates the page.

The flowchart of logging on to the chat room:

 

Message sending flowchart:

After completing the online staff list, sending information, and information display, add the specified online staff for private chat, built-in common terms, font color settings, font size settings, and emoticons selection, A living text meeting room is basically complete. You can also set the conference room permissions, the valid time, the login permission, and the chat record. This function is more practical.

A programmer encounters a small problem in the development process, that is, an abnormal offline person. onlinemap always has his information. In onlinemap, the user name is saved and the logon time is added ". Because the online client needs to regularly check whether there are the latest messages, the detection time is also saved to onlinemap during the detection. Once the detection time is delayed, the system determines that the user is offline abnormally.

Final:

 

Although the implementation of JSP, Java, and Ajax text chat rooms is simple, it takes time to process some details.

Related Article

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.