orus-io / elm-nats / Nats.Socket

A socket defines a connection to a nats server


type Status
    = Undefined
    | Opening
    | Opened
    | Connecting
    | Connected
    | Closing
    | Closed
    | Error String

Possible statuses of a socket


type alias Socket =
Nats.Internal.Types.Socket

Representation of a Nats connection properties

new : String -> String -> Socket

Initialize a Socket with a unique ID and a endpoint url

The 'sid' can be used in various places of the API to choose which socket should handle an effect or a subscription.

setDefault : Socket -> Socket

Set this socket as the default one

If an app has several opened sockets, one must be the default one. By default, the default socket is the first to be opened. This function can be used to designate an arbitrary socket as the default one.

If several sockets have this flag, one of them will be picked

withDebug : Basics.Bool -> Socket -> Socket

Enable/disable debug mode on the socket

If the Config debug is on, all sockets will have debug enabled no matter what value is given to this function.

Authentication

connectOptions : String -> String -> Nats.Protocol.ConnectOptions

Build the smallest ConnectOptions possible

You generally want to combine it with 'withUserPass' or 'withAuthToken'

withAuthToken : String -> Nats.Protocol.ConnectOptions -> Nats.Protocol.ConnectOptions

Authenticate with a auth token

withUserPass : String -> String -> Nats.Protocol.ConnectOptions -> Nats.Protocol.ConnectOptions

Authenticate with a username and a password