WebSockets
Learn to establish a long-lived connection with the server via WebSockets.
What are WebSockets?
WebSocket protocol allows for simultaneous two-way communication between the client and the server. Applications such as chatting apps and multiplayer games that rely on real-time connection with the server use WebSockets for their communication.
GetX’s internal networking library, GetConnect
, allows us to establish long-lived connections with the server over WebSockets. This lesson will teach us how to manage a socket connection with the server and listen to real-time updates.
Establishing connection
We manage a WebSocket connection in GetConnect
using the GetSocket
class. With GetSocket
, we get the methods to establish a connection, close it, and listen to the messages that pass to and from the client and server. To establish a connection, we follow three simple steps:
Create an instance of
GetConnect
. We use it to create a socket connection.
Get hands-on with 1400+ tech skills courses.