Real-time communication is a holy grail of web development, and we finally have the ability to incorporate it in our applications, thanks to the Web Sockets API. But as with most browser APIs, the Web Sockets API is rather low level, and if you have spent any amount of time with it, then you know how difficult it can be to use effectively.
Today, however, we have supercomputers in our pockets that we use every single day, and users expect the same real-time experience across web, mobile, and even desktop. In this series, you'll learn about Channels, a platform that allows you to give your users the seamless real-time experience they want.
What Is Channels?
When it comes to writing real-time applications, what you need is an infrastructure that you can use (and reuse) in all your applications on all your supported platforms. It would be fun to write that infrastructure, but if you're like me, your job is to build and produce applications—you don't have time to roll your own real-time solution.
What you really need is something like a product called "Channels" from Pusher. Channels is a platform that comes with everything you need to incorporate real-time communication in all your web, mobile, and desktop applications.
Channels provides flexible publish and subscribe messaging with their simple, event-based API.
By using their extensive server libraries, you can trigger events from your server applications and listen for those events on your client. Let's take a brief look at what libraries are available because this is probably the most important thing that you would be interested in—at least I know I would be because I want to make sure that my technologies are supported!
Libraries fall into two categories:
- client libraries
- server libraries
We typically publish our messages and events from the server and listen for them on the client, but Channels also supports client events—making it possible to publish messages from the client (although that isn't something that we always want to do).
You can see that the official libraries that are written and maintained by Pusher support all the major platforms. On the front end, Pusher has libraries for:
- iOS (both Swift and Objective C)
And on the server, you'll find support for:
If you use another language or platform, there are many community libraries available—for example, for ActionScript, Android (although there is also official support for Android), C++, Cold Fusion, Dart, PERL, and React Native. These community libraries may not implement everything, but they are a good place to start.
Channels is so much more than just publishing and subscribing to messages.
You can create and use private channels so that only authorized users can subscribe to them. This means that you need to authenticate users, and you can seamlessly integrate Channels authentication with your own authentication scheme.
You can also create specialized private channels, called Presence Channels, that let you see the users that subscribe to a particular channel, and it makes it extremely easy to build collaborative applications, games, and any other type of application where you need to know who is online.
As a platform, Channels gives you everything you need to monitor metrics and alerts. You can view a variety of metrics about the messages sent over your channels, such as the number of messages, their type, and their size. You'll also have information about the connections and how clients are connecting both to your app and the Channels platform. You can also integrate all this data with other third-party tools like Datadog and Slack.
There are debugging tools available for whenever you run into an issue, and web hooks are supported so that your server can be updated and notified when events occur within Channels. You can also query the state of your connected users with a simple query API.
There are a lot of wonderful things to discover about Channels, and we will be looking at them over the course of the next few videos. So stay tuned! And be sure to visit the Pusher site to learn more. They have a lot of information about specific use-cases as well as tutorials and information about getting started.