![]() ![]() That’s what we’re going to use in this post. The web_socket_channel Dart WebSocket package is Google-developed and very easy to use. What I’m going to do in this post, though, is show you everything you need to know in order to build a real time app, leaving the rest to you and avoid showing how to interact with a specific database, how to build a very specific complex user interface: the example is simply going to be an app showing the latest message sent by an user as an announcement to every connected user. I used the example of a chat app in my book to show how to use Firebase, but that was to show as many aspects of Flutter and Firebase as possible in one example, and it is a cool example. That’s a very good example but, in my view, it’s not a great example for a blog post, unless what one wants to teach is how to build a chat app and not how to use WebSockets. What We’re Going to BuildĪ very common application for WebSockets is building a chat app. The main difference you would notice in the example in a tutorial is that Socket.io supports server broadcasting by default, meaning you don’t have to manually iterate over the connected clients to send the message to each, as that is a feature of Socket.io itself. ![]() The way Socket.io does it is rather the other way around, using its own engine to initiate the connection, upgrading to WebSocket if it’s supported. ![]() WebSocket is a protocol (just like HTTP) and there are some packages and libraries to use it directly, but a very popular alternative to doing that is using Socket.io, which is a library that may or may not use WebSocket as its communication protocol, given that it has its own real-time communication engine that is used in case there is no way to establish a WebSocket-based connection. It won’t be about Socket.IO, which might be the focus of another post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |