Documentation
¶
Index ¶
- Constants
- Variables
- type Conn
- type Context
- type Event
- type EventHandler
- type Group
- type IdGenerator
- type MiddlewareFunc
- type Router
- type Server
- func (s *Server) BroadcastTo(room, event string, msg []byte)
- func (s *Server) BroadcastToAll(event string, msg []byte)
- func (s *Server) Close()
- func (s *Server) Group(m ...MiddlewareFunc) (g *Group)
- func (s *Server) Handler(e string) EventHandler
- func (s *Server) On(e string, fn EventHandler)
- func (s *Server) SetLog(log logger.Logger)
- func (e *Server) SetRouter(event string, router Router)
- func (s *Server) Start() error
- func (s *Server) Started() bool
- func (s *Server) Use(middleware ...MiddlewareFunc)
Constants ¶
View Source
const ( MaxWorkId = -1 ^ (-1 << numWorkerBits) MaxSequence = -1 ^ (-1 << numSequenceBits) )
Variables ¶
View Source
var ( ErrConnClosed = errors.New("use of closed network connection") ErrMessageTimeout = errors.New("timeout") )
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
Id() string
IsClosed() bool
Close()
Get(key string) interface{}
Set(key string, value interface{})
RemoteAddr() net.Addr
Emit(event string, v interface{}) error
Ack(event string, v interface{}, r interface{}) error
BroadcastToAll(event string, msg []byte)
BroadcastTo(room, event string, msg []byte)
Join(room string)
Leave(room string)
}
type Context ¶
type Context interface {
Id() string
IsClosed() bool
Close()
Get(key string) interface{}
Set(key string, value interface{})
RemoteAddr() net.Addr
Emit(event string, v interface{}) error
Ack(event string, v interface{}, r interface{}) error
BroadcastToAll(event string, msg []byte)
BroadcastTo(room, event string, msg []byte)
Join(room string)
Leave(room string)
Content() []byte
Packet() protocol.Packet
Bind(v interface{}) error
Reply(v interface{}) error
Conn() Conn
Logger() logger.Logger
}
type EventHandler ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Group ¶
func (g *Group) Group(middleware ...MiddlewareFunc) (sg *Group)
func (*Group) Handler ¶
func (g *Group) Handler(e string) EventHandler
func (*Group) On ¶
func (g *Group) On(e string, fn EventHandler)
func (*Group) Use ¶
func (g *Group) Use(middleware ...MiddlewareFunc)
type IdGenerator ¶
type IdGenerator struct {
// contains filtered or unexported fields
}
func NewSnowFlake ¶
func NewSnowFlake(workerId uint16) (*IdGenerator, error)
New returns a new snowflake node that can be used to generate snowflake
func (*IdGenerator) Generate ¶
func (sf *IdGenerator) Generate() uint64
Next creates and returns a unique snowflake ID
type MiddlewareFunc ¶
type MiddlewareFunc func(EventHandler) EventHandler
type Router ¶
type Router interface {
Use(args ...MiddlewareFunc)
On(e string, fn EventHandler)
Handler(e string) EventHandler
// contains filtered or unexported methods
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) BroadcastTo ¶ added in v0.4.0
func (*Server) BroadcastToAll ¶ added in v0.4.0
func (*Server) Group ¶
func (s *Server) Group(m ...MiddlewareFunc) (g *Group)
func (*Server) Handler ¶
func (s *Server) Handler(e string) EventHandler
func (*Server) On ¶
func (s *Server) On(e string, fn EventHandler)
func (*Server) Use ¶
func (s *Server) Use(middleware ...MiddlewareFunc)
Click to show internal directories.
Click to hide internal directories.