sono.land — Real-time Communication for Deno
One year to the day, and almost three since its announcement, Ryan Dahl, the creator of Node, and his team released Deno v1.0. The alternative runtime sought to alleviate the pain points many developers, including Dahl himself, have with Node, such as its relative lack of security and its infamous package manager. The case for adopting Deno is strong as support for and interest in Deno continues to grow, especially in light of Dahl announcing the Deno company in March, which pledges to keep Deno MIT licensed. With all the excitement surrounding Deno, Team Sono is proud to announce sono.land v1.1.
What is sono.land?
sono.land is a Deno third-party module that provides a way for developers to create real-time applications on the Deno runtime. sono.land is capable of making WebSocket connections through a client-side and server-side module, which work together to create a coherent user experience. Using sono.land is as easy as importing the client-side and server-side modules and initializing the sono.land class objects. From there, the built-in methods on the Sono and SonoClient classes aim to offer the abstractions needed for a real-time communication application. You can think of us as a Deno version of Socket.io. We offer the ability to send out custom events and listen to those events with an event listener.
How does it work?
sono.land wraps around the module /ws in Deno’s standard library to create a class object. This class object handles WebSocket events, mostly interacting with the message event. Messages are sent back and forth client to server without having to make requests to see if there are any new ones, which is what makes sono.land real-time.
The server class object features Channels as a way to send messages to Clients that share the same Channel. Channels provide flexibility in determining how data flows between one Client to another or many others.
The client class object provides a way to make a WebSocket connection. It’s used primarily to gain access to properties such as WebSocket EventHandlers and sono.land and functionality like custom event handlers.
What can I do with it?
On sono.land, our website features extensive documentation of all the available methods. You can find tutorials that include a chatroom capable of sending messages to all other connected peers by essentially making a single request to open a WebSocket connection. With WebSockets, clients receive messages as soon as they are sent through the API’s event-driven responses without the aid of long-polling. Furthermore, another tutorial details a live video-chat application that makes use of the sono.land library and WebRTC APIs. It allows for different channels and multiple people in the same room.
Thank you for reading! Feel free to reach out to any of us through the following platforms. We welcome any contributions to improve sono.land.
Meet the Team
Chris Ejercito — LinkedIn — GitHub
sono.land is a beta product developed in partnership with OSLabs.