Documentation ¶
Index ¶
- Variables
- func IsNormalClose(err error) bool
- type AcceptOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) Dial(ctx context.Context, url string) error
- func (c *Client) Emit(ctx context.Context, event string, data []byte) error
- func (c *Client) EmitWithAck(ctx context.Context, event string, data []byte) ([]byte, error)
- func (c *Client) On(event string, handler Handler) *Client
- func (c *Client) OnConnect(handler ConnectHandler) *Client
- func (c *Client) OnDisconnect(handler DisconnectHandler) *Client
- func (c *Client) OnError(handler ErrorHandler) *Client
- func (c *Client) OnUnknownEvent(handler Handler) *Client
- func (c *Client) Ping(ctx context.Context) error
- type ClientOption
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Data() *store.Store
- func (c *Conn) Emit(ctx context.Context, event string, data []byte) error
- func (c *Conn) EmitWithAck(ctx context.Context, event string, data []byte) ([]byte, error)
- func (c *Conn) HttpRequest() *http.Request
- func (c *Conn) Id() uint64
- func (c *Conn) Ping(ctx context.Context) error
- type ConnectHandler
- type DialOptions
- type DisconnectHandler
- type ErrorHandler
- type Handler
- type HandlerFunc
- type Rooms
- func (s *Rooms) AllConns() []*Conn
- func (s *Rooms) Clear(rooms ...string)
- func (s *Rooms) Get(connId uint64) (*Conn, bool)
- func (s *Rooms) Join(conn *Conn, rooms ...string)
- func (s *Rooms) LeaveByConnId(id uint64, rooms ...string)
- func (s *Rooms) Len(room string) int
- func (s *Rooms) Rooms() []string
- func (s *Rooms) ToBroadcast(rooms ...string) []*Conn
- type Server
- func (s *Server) On(event string, handler Handler) *Server
- func (s *Server) OnConnect(handler ConnectHandler) *Server
- func (s *Server) OnDisconnect(handler DisconnectHandler) *Server
- func (s *Server) OnError(handler ErrorHandler) *Server
- func (s *Server) OnUnknownEvent(handler Handler) *Server
- func (s *Server) Rooms() *Rooms
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown()
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrClientClosed = errors.New("client closed")
)
Functions ¶
func IsNormalClose ¶
Types ¶
type AcceptOptions ¶
type AcceptOptions = websocket.AcceptOptions
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func (*Client) EmitWithAck ¶
func (*Client) OnConnect ¶
func (c *Client) OnConnect(handler ConnectHandler) *Client
func (*Client) OnDisconnect ¶
func (c *Client) OnDisconnect(handler DisconnectHandler) *Client
func (*Client) OnError ¶
func (c *Client) OnError(handler ErrorHandler) *Client
func (*Client) OnUnknownEvent ¶
type ClientOption ¶
type ClientOption func(*clientOptions)
func WithClientDialOptions ¶
func WithClientDialOptions(opts *DialOptions) ClientOption
func WithClientReadLimit ¶
func WithClientReadLimit(limit int64) ClientOption
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) EmitWithAck ¶
func (*Conn) HttpRequest ¶
type ConnectHandler ¶
type ConnectHandler func(conn *Conn)
type DialOptions ¶
type DialOptions = websocket.DialOptions
type DisconnectHandler ¶
type ErrorHandler ¶
type HandlerFunc ¶
type Rooms ¶
type Rooms struct {
// contains filtered or unexported fields
}
func (*Rooms) LeaveByConnId ¶
func (*Rooms) ToBroadcast ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
func (*Server) OnConnect ¶
func (s *Server) OnConnect(handler ConnectHandler) *Server
func (*Server) OnDisconnect ¶
func (s *Server) OnDisconnect(handler DisconnectHandler) *Server
func (*Server) OnError ¶
func (s *Server) OnError(handler ErrorHandler) *Server
func (*Server) OnUnknownEvent ¶
type ServerOption ¶
type ServerOption func(*serverOptions)
func WithServerAcceptOptions ¶
func WithServerAcceptOptions(opts *AcceptOptions) ServerOption
func WithServerReadLimit ¶
func WithServerReadLimit(limit int64) ServerOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.