Versions in this module Expand all Collapse all v0 v0.0.1 Aug 3, 2024 Changes in this version + var ErrCompressionNegotiation = errors.New("invalid compression negotiation") + var ErrConnClosed = net.ErrClosed + var ErrHandshake = errors.New("handshake error") + var ErrSubprotocolNegotiation = errors.New("sub-protocol negotiation failed") + var ErrTextEncoding = errors.New("invalid text encoding") + var ErrUnauthorized = errors.New("unauthorized") + var ErrUnsupportedProtocol = errors.New("unsupported protocol") + func Recovery(logger Logger) + type Broadcaster struct + func NewBroadcaster(opcode Opcode, payload []byte) *Broadcaster + func (c *Broadcaster) Broadcast(socket *Conn) error + func (c *Broadcaster) Close() error + type BuiltinEventHandler struct + func (b BuiltinEventHandler) OnClose(socket *Conn, err error) + func (b BuiltinEventHandler) OnMessage(socket *Conn, message *Message) + func (b BuiltinEventHandler) OnOpen(socket *Conn) + func (b BuiltinEventHandler) OnPing(socket *Conn, payload []byte) + func (b BuiltinEventHandler) OnPong(socket *Conn, payload []byte) + type ClientOption struct + Addr string + CheckUtf8Enabled bool + HandshakeTimeout time.Duration + Logger Logger + NewDialer func() (Dialer, error) + NewSession func() SessionStorage + ParallelEnabled bool + ParallelGolimit int + PermessageDeflate PermessageDeflate + ReadBufferSize int + ReadMaxPayloadSize int + Recovery func(logger Logger) + RequestHeader http.Header + TlsConfig *tls.Config + WriteBufferSize int + WriteMaxPayloadSize int + type CloseError struct + Code uint16 + Reason []byte + func (c *CloseError) Error() string + type ConcurrentMap struct + func NewConcurrentMap[K comparable, V any](size ...uint64) *ConcurrentMap[K, V] + func (c *ConcurrentMap[K, V]) Delete(key K) + func (c *ConcurrentMap[K, V]) GetSharding(key K) *Map[K, V] + func (c *ConcurrentMap[K, V]) Len() int + func (c *ConcurrentMap[K, V]) Load(key K) (value V, ok bool) + func (c *ConcurrentMap[K, V]) Range(f func(key K, value V) bool) + func (c *ConcurrentMap[K, V]) Store(key K, value V) + type Config struct + CheckUtf8Enabled bool + Logger Logger + ParallelEnabled bool + ParallelGolimit int + ReadBufferSize int + ReadMaxPayloadSize int + Recovery func(logger Logger) + WriteBufferSize int + WriteMaxPayloadSize int + type Conn struct + func NewClient(handler Event, option *ClientOption) (*Conn, *http.Response, error) + func NewClientFromConn(handler Event, option *ClientOption, conn net.Conn) (*Conn, *http.Response, error) + func (c *Conn) Async(f func()) + func (c *Conn) Context() context.Context + func (c *Conn) LocalAddr() net.Addr + func (c *Conn) NetConn() net.Conn + func (c *Conn) ReadLoop() + func (c *Conn) RemoteAddr() net.Addr + func (c *Conn) Session() SessionStorage + func (c *Conn) SetDeadline(t time.Time) error + func (c *Conn) SetNoDelay(noDelay bool) error + func (c *Conn) SetReadDeadline(t time.Time) error + func (c *Conn) SetWriteDeadline(t time.Time) error + func (c *Conn) SubProtocol() string + func (c *Conn) WriteAsync(opcode Opcode, payload []byte, callback func(error)) + func (c *Conn) WriteClose(code uint16, reason []byte) + func (c *Conn) WriteMessage(opcode Opcode, payload []byte) error + func (c *Conn) WritePing(payload []byte) error + func (c *Conn) WritePong(payload []byte) error + func (c *Conn) WriteString(s string) error + func (c *Conn) Writev(opcode Opcode, payloads ...[]byte) error + func (c *Conn) WritevAsync(opcode Opcode, payloads [][]byte, callback func(error)) + type Dialer interface + Dial func(network, addr string) (c net.Conn, err error) + type Event interface + OnClose func(socket *Conn, err error) + OnMessage func(socket *Conn, message *Message) + OnOpen func(socket *Conn) + OnPing func(socket *Conn, payload []byte) + OnPong func(socket *Conn, payload []byte) + type Logger interface + Error func(v ...any) + type Map struct + func NewMap[K comparable, V any](size ...int) *Map[K, V] + func (c *Map[K, V]) Delete(key K) + func (c *Map[K, V]) Len() int + func (c *Map[K, V]) Load(key K) (value V, ok bool) + func (c *Map[K, V]) Range(f func(K, V) bool) + func (c *Map[K, V]) Store(key K, value V) + type Message struct + Data *bytes.Buffer + Opcode Opcode + func (c *Message) Bytes() []byte + func (c *Message) Close() error + func (c *Message) Read(p []byte) (n int, err error) + type Opcode uint8 + const OpcodeBinary + const OpcodeCloseConnection + const OpcodeContinuation + const OpcodePing + const OpcodePong + const OpcodeText + type PermessageDeflate struct + ClientContextTakeover bool + ClientMaxWindowBits int + Enabled bool + Level int + PoolSize int + ServerContextTakeover bool + ServerMaxWindowBits int + Threshold int + type Server struct + OnError func(conn net.Conn, err error) + OnRequest func(conn net.Conn, br *bufio.Reader, r *http.Request) + func NewServer(eventHandler Event, option *ServerOption) *Server + func (c *Server) GetUpgrader() *Upgrader + func (c *Server) Run(addr string) error + func (c *Server) RunListener(listener net.Listener) error + func (c *Server) RunTLS(addr string, certFile, keyFile string) error + type ServerOption struct + Authorize func(r *http.Request, session SessionStorage) bool + CheckUtf8Enabled bool + HandshakeTimeout time.Duration + Logger Logger + NewSession func() SessionStorage + ParallelEnabled bool + ParallelGolimit int + PermessageDeflate PermessageDeflate + ReadBufferSize int + ReadMaxPayloadSize int + Recovery func(logger Logger) + ResponseHeader http.Header + SubProtocols []string + TlsConfig *tls.Config + WriteBufferSize int + WriteMaxPayloadSize int + type SessionStorage interface + Delete func(key string) + Len func() int + Load func(key string) (value any, exist bool) + Range func(f func(key string, value any) bool) + Store func(key string, value any) + type Upgrader struct + func NewUpgrader(eventHandler Event, option *ServerOption) *Upgrader + func (c *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request) (*Conn, error) + func (c *Upgrader) UpgradeFromConn(conn net.Conn, br *bufio.Reader, r *http.Request) (*Conn, error)