Helpers for Socket types as part of an Interface
An Interface for closing a given connection
An Interface for sending data to the server.
It's common to pair this with Json.Encode.encode 0
to send json.
An Interface for detecting when data has been sent from the server
An
Interfacefor opening a connection on a given address, notifying you when it's connected or disconnectedOnce this detects it's available, make sure to set your state's
SocketIdso you can actually send and receive messages. And once it's disconnected, set your state'sSocketIdback to nothing: