Versions in this module Expand all Collapse all v0 v0.1.1 Feb 28, 2024 v0.1.0 Feb 21, 2024 Changes in this version + const ClientConnection + const DefaultConnectionTimeout + const DefaultReadTimeout + const DefaultServerHost + const DefaultServerPort + const DefaultWriteTimeout + const ServerConnection + type AtomicConnectionState struct + func NewAtomicConnectionState(initial ConnectionState) AtomicConnectionState + func (a *AtomicConnectionState) Get() ConnectionState + func (a *AtomicConnectionState) Set(val ConnectionState) + type Connection interface + Close func() error + IsConnected func() bool + ListenAndServe func(ctx context.Context, callbackFn StateHandler) error + Read func(ctx context.Context) ([]byte, error) + Write func(ctx context.Context, data []byte) error + func NewConnection(role ConnectionRole, opts ...OptionFunction) (Connection, error) + type ConnectionRole string + type ConnectionState int32 + const Connected + const ConnectionPending + const Disconnected + const Disconnecting + const NotConnected + type Message struct + Data []byte + ID string + Source string + Type MessageType + type MessageHandler func(data []byte) error + type MessageType int + const Ack + const Connect + const Data + const Disconnect + type OptionFunction func(*connection) + func WithConnectionTimeout(timeout time.Duration) OptionFunction + func WithReadHandler(handler MessageHandler) OptionFunction + func WithReadTimeout(timeout time.Duration) OptionFunction + func WithServerHost(host string) OptionFunction + func WithServerPort(port int) OptionFunction + func WithWriteTimeout(timeout time.Duration) OptionFunction + type StateHandler func(state ConnectionState) error