9 Scenarios for using WebSockets

Source: Internet
Author: User

No other technology can provide true two-way communication like WebSocket, and many web developers still rely on Ajax for long polling implementations. (Note: I think long polling is creative and versatile, although this is a less than perfect solution (hack)) lack of enthusiasm for websocket, perhaps because of the fragility of his security years ago, or the lack of browser support, either way, these two problems have been solved.

The way to decide whether the work at hand requires the use of WebSocket technology is simple:

    • Does your app offer multiple users to communicate with each other?
    • Is your application a display of frequently changing data on the server side?

If your answer is yes, please consider using WebSocket. If you are still unsure and want more inspiration, this has some killer case.

1. Social subscription

One of the benefits of social apps is being able to instantly know what your friends are doing. It sounds a bit scary, but we all like it. You don't want to know when a family member wins a pie-making contest or a friend's engagement in a few minutes. You are online, so updates to your subscription should be in real time.

2. Multi-player game

The network is rapidly turning into a gaming platform. Without the use of plugins (I mean Flash), web developers can now implement and experience high-performance games in their browsers. Whether you're dealing with DOM elements, CSS animations, HTML5 canvas, or trying to use WEBGL, the interaction between players is critical. I don't want my opponent to move after I pull the trigger.

3. Collaborative editing/programming

We live in the age of distributed development teams. Usually a copy of a document is used to meet the needs of the job, but you end up needing a way to merge all the edited copies. Version control systems, such as Git, can help with some files, but when Git finds a conflict that it can't resolve, you still need to track people's History of change. With a collaborative solution, such as websocket, we are able to work in the same document, eliminating all merge versions. It's easy to see who's editing what or who you're modifying the same part of the document.

4. Tap Stream data

Analyzing the user's interaction with your site is key to improving your site. The overhead of HTTP allows us to prioritize and collect only the most important parts of the data. Then, after six months of offline analysis, we realized that we should collect a different standard of judgment-one that doesn't seem so important but now affects a key decision. Using WebSocket, you can send unrestricted data by the client compared to the cost of the HTTP request. Want to track mouse movement in addition to page loading? Just send this data to the server via the WebSocket connection and store it in your favorite NoSQL database (MongoDB is a good way to record events like this). Now you can clearly know what's going on by playing back the user's actions on the page.

5. Stock Fund Quotes

The financial world is changing rapidly-almost every millisecond. Our human brain can't continue to process so much data at that rate, so we've written algorithms to help us deal with these things. Although you may not necessarily be dealing with high-frequency transactions, outdated information can only lead to losses. When you have a display disk to track the companies you are interested in, you definitely want to know their value at any time, not the data 10 seconds ago. You can use WebSocket to stream these data changes without waiting.

6. Live Sports Update

Now we're talking about a stupid thing that makes people passionate--sports. I'm not a sports enthusiast, but I know what sports fans want. When the Patriots are playing, my brother-in-law will be immersed in the game and can not extricate themselves. It's a state of madness, completely heartfelt. I don't understand this, but I admire the strong link between them and sports, so the last thing I can do is give him the experience to reduce the delay. If you include sports News in your website app, WebSocket can help your users get real-time updates.

7. Multimedia Chat

Video conferencing is not a substitute for meeting real people, but video conferencing is a good choice when you can't see the person you're talking to in the same room. Although video conferencing privatization is "good", its use is cumbersome. I'm a fan of open networks, so using WebSockets Getusermedia API and HTML5 audio and video elements is obviously a good choice. The advent of WEBRTC is a logical combination of what I have just outlined, it looks promising, but it lacks the support of the current browser, so it is disqualified from becoming a candidate.

8. Location-based applications

More and more developers are borrowing the GPS capabilities of mobile devices to implement their location-based Web applications. You can collect more detailed data if you keep track of the user's location (for example, if the run should be used to record motion tracks). If you want to update the network data dashboard in real-time (which can be said to be a trainer for monitoring athletes), the HTTP protocol looks awkward. Borrowing WebSocket TCP links can let the data fly up.

9. Online Education

Schooling costs more and more, but the Internet becomes faster and cheaper. Online education is a good way to learn, especially if you can communicate with teachers and other students. Naturally, WebSockets is a good choice for multimedia chatting, text chatting and other advantages such as working with others on the public digital blackboard to draw ...

9 Scenarios for using WebSockets

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.