Versions in this module Expand all Collapse all v1 v1.1.0 Jan 2, 2020 v1.0.0 Feb 1, 2019 Changes in this version + type Channel struct + func (ch *Channel) AddListener(endpoint string, ...) error + func (ch *Channel) AddMiddleware(...) + func (ch *Channel) GetPeer(id uuid.UUID) *peer + func (ch *Channel) HandlePeer(peer *peer) + func (ch *Channel) Init() + func (ch *Channel) ListPeers() []uuid.UUID + func (ch *Channel) NewPeer(c *websocket.Conn, uri string) *peer + func (ch *Channel) Send(client uuid.UUID, endpoint string, body []byte) ([]byte, error) + func (ch *Channel) SetHooks(onConnect *func(id uuid.UUID, uri string, remoteAddr string) error, ...) + type ChannelOptions struct + ProtoHandshake time.Duration + ProtoRead time.Duration + ProtoReconnect time.Duration + ProtoWrite time.Duration + type Client struct + Channel *Channel + URL url.URL + func NewClient(url url.URL, channelOptions ChannelOptions) *Client + func (c *Client) AddListener(endpoint string, listener func([]byte) ([]byte, error)) error + func (c *Client) IsConnected() bool + func (c *Client) Listen() + func (c *Client) Send(endpoint string, body []byte) ([]byte, error) + func (c *Client) SetHooks(onConnect *func() error, onDisconnect *func()) + type Conn interface + Close func() error + NextReader func() (messageType int, r io.Reader, err error) + NextWriter func(int) (io.WriteCloser, error) + RemoteAddr func() net.Addr + SetWriteDeadline func(time.Time) error + type ErrorCode int + const BadRequestCode + const ClientNotConnectedCode + const InternalErrorCode + const LocalErrorCode + const NotFoundCode + const TimeoutCode + type ProtocolError struct + Code ErrorCode + Message string + Reason *string + func ApplyReason(fn func(message string, reason *string) ProtocolError, message string, ...) *ProtocolError + func BadRequest(message string, reason *string) ProtocolError + func ClientNotConnected(message string, reason *string) ProtocolError + func InternalError(message string, reason *string) ProtocolError + func LocalError(message string, reason *string) ProtocolError + func NotFound(message string, reason *string) ProtocolError + func Timeout(message string, reason *string) ProtocolError + func (e ProtocolError) Error() string + type Receiver interface + type Server struct + Addr string + Channel *Channel + Path string + func NewServer(addr string, path string, channelOptions ChannelOptions) *Server + func (ch *Server) AddMiddleware(...) + func (s *Server) AddListener(endpoint string, ...) error + func (s *Server) IsConnected(client uuid.UUID) bool + func (s *Server) Listen() + func (s *Server) Peers() []uuid.UUID + func (s *Server) Send(client uuid.UUID, endpoint string, body []byte) ([]byte, error) + func (s *Server) SetHooks(onConnect *func(id uuid.UUID, uri string, remoteAddr string) error, ...)