Versions in this module Expand all Collapse all v1 v1.0.0 Jan 5, 2024 Changes in this version + var AuthTimeout = time.Second * 5 + var ErrOffline = errors.New("offline") + var ErrQueueRequired = errors.New("queue is required") + var ReadTimeout time.Duration + var ServerPingInterval = time.Second * 30 + var TCPMaxPackLen uint32 = 4 * 1024 * 1024 + var WriteTimeout = time.Minute + type Actor interface + BeforeReceive func(dv *Device, data []byte) ([]byte, error) + BeforeSend func(dv *Device, data []byte) ([]byte, error) + Bye func(kicker *Device, reason string, dv *Device) []byte + OnClose func(dv *Device) + OnReceive func(dv *Device, data []byte) + OnSent func(dv *Device, data []byte) + Ping func() []byte + type Device struct + func CreateDevice(uid interface{}, id string) *Device + func (p *Device) GetMeta(key string) string + func (p *Device) ID() string + func (p *Device) PutMeta(key string, val string) + func (p *Device) UID() interface{} + type Hub struct + func CreateWsHandler(hub *Hub, config *HubConfig, txt bool, auth WsAuthFunc) (*Hub, http.Handler) + func Listen(hub *Hub, config *HubConfig, addr string, auth TCPAuthFunc) (*Hub, error) + func (p *Hub) CheckOnline(uid interface{}) bool + func (p *Hub) Kick(uid interface{}) + func (p *Hub) Online() []interface{} + func (p *Hub) Send(to interface{}, b []byte, ttl uint32) error + type HubConfig struct + Actor Actor + Q Queue + Sso bool + type Queue interface + Deq func(ctx context.Context, uid interface{}) ([]byte, error) + Enq func(ctx context.Context, uid interface{}, data []byte, ttl ...uint32) error + Len func(ctx context.Context, uid interface{}) (int, error) + type TCPAuthFunc func([]byte) (*Device, error) + type WsAuthFunc func(*http.Request) (*Device, error)