August is the month of important new releases and features for Altogic. Today, we are excited to announce the release of Realtime functionality that will open up new use cases that you can develop in your Altogic backends.
What is realtime?
Realtime is a communication layer between your backend app and your frontend app. It maintains persistent connections with the client using WebSockets. If a server wants to push new data to clients, it can do it instantly using Altogic realtime which is highly flexible, and easy to integrate.
Under the hood, WebSocket is bidirectional, a full-duplex (e.g., simultaneous data transmission) protocol that is used in the same scenario of client-server communication. It is a stateful protocol, which means the connection between client and server will keep alive until it is terminated by either party (client or server). After closing the connection by either of the client and server, the connection is terminated from both ends.
Why do we need WebSockets?
The traditional approach toward building web applications that require realtime communication between a client and a server has required the use of HTTP to continuously poll the server to fetch updates and send upstream data via distinct HTTP calls. The approach might have worked, nonetheless, it was still a misuse of the HTTP protocol. This resulted in a variety of problems such as making unnecessary HTTP requests flooding the network and potentially running out the server capacity and ending up discarding further requests.
HTML 5 Websockets combined with the WebSocket API, provides an alternative to HTTP polling for two-way communication from a web page to a remote server. This opens up space for endless possibilities for the application developers to leverage and build amazing applications.
When not to use WebSockets?
As I have briefly mentioned above, WebSocket can be used if we want any realtime updated or continuous streams of data that are being transmitted over the network. If we want to fetch legacy data or want to get the data less frequently to process it with an application we should go with the HTTP protocol. Legacy data that is not required very frequently or fetched sometimes can be queried by a simple RESTful API request, so in this scenario, it’s better not to use WebSocket.
Five amazing use cases of WebSockets
One of the benefits of social apps is knowing what all your friends are doing when they do it. Realtime feeds provide your apps the ability to process real-time feeds, notifications, social likes, and shares, and instantly share all that with your users in realtime.
As the teams are working remotely, we need to figure out a way to merge edited copies of the team documents. With a collaborative solution like WebSockets, team members can work on the same document (e.g., similar to Google Docs). It is easy to see who is editing what and if you’re working on the same portion of a document as someone else.
Real-time Data Visualization
With WebSockets you can create visually appealing data representations that will automatically update as and when new data arrives in your backend, and that too without having the need to poll the data.
You can develop WhatsApp-like realtime chat applications using WebSockets. Combined with media upload (e.g., image, audio and video), you can provide a full multimedia chat experience to your users.
Building applications like location-based intelligence, geo-fencing, track and trace become all the more simplified with Websockets allowing developers to share location updates in realtime.
What about Altogic Realtime?
Through the Altogic Client Library you can start developing realtime applications and develop any of the 5 uses cases above and more. With Altogic realtime, your app clients (e.g. your users) can;
- Join and leave channels (e.g., rooms)
- Broadcast messages to all connected app users
- Send messages to specific channels
- Get the list of channel members
- Update presence data and broadcast across all joined channels
- Listen to messages from other users
I am quite excited to see what you will be building with this new module of Altogic. If you have any questions about Altogic realtime or want to share what you have built, please post a message in our community from or discord channel.