Versions in this module Expand all Collapse all v1 v1.0.0 Nov 24, 2023 Changes in this version + var ErrBrokenPipe = errors.New("broken low-level pipe") + var ErrBufferExceed = errors.New("session send buffer exceed") + var ErrCloseClosedGroup = errors.New("close closed group") + var ErrCloseClosedSession = errors.New("close closed session") + var ErrClosedGroup = errors.New("group closed") + var ErrConnClosed = errors.New("连接已关闭") + var ErrConnNotReady = errors.New("连接末准备好") + var ErrDialInterrupt = errors.New("dial interrupt") + var ErrDialTimeout = errors.New("dial timeout") + var ErrHandShake = errors.New("handshake failed") + var ErrHandShakeAck = errors.New("handshake ack 出错") + var ErrHeartbeatTimeout = errors.New("heartbeat timeout") + var ErrIllegalUID = errors.New("illegal uid") + var ErrInvalidAddress = errors.New("invalid address") + var ErrInvalidHandler = errors.New("invalid handler") + var ErrInvalidMessage = errors.New("invalid message") + var ErrInvalidPacket = errors.New("invalid packet") + var ErrInvalidRegisterReq = errors.New("invalid register request") + var ErrInvalidState = errors.New("invalid state") + var ErrKick = errors.New("被踢下线") + var ErrMemberNotFound = errors.New("member not found in the group") + var ErrNotHandshake = errors.New("没握手成功就发了数据包过来") + var ErrNotWorking = errors.New("非正常状态,无法发送消息") + var ErrSessionDuplication = errors.New("session has existed in the current group") + var ErrSessionOnNotify = errors.New("current session working on notify mode") + var ErrSprotoRequestType = errors.New("sproto request type") + var ErrSprotoResponseType = errors.New("sproto response type") + type Conn struct + func (self *Conn) Close() error + func (self *Conn) Kick(reason string) error + func (self *Conn) Push(route string, data []byte) error + func (self *Conn) Recv(ctx context.Context) (msg *Message, err error) + func (self *Conn) RemoteAddr() net.Addr + func (self *Conn) Response(mid uint64, data []byte) error + func (self *Conn) SendServerDownPacket(reason string) error + func (self *Conn) SendServerMaintainPacket(reason string) error + func (self *Conn) SendServerResumePacket(reason string) error + func (self *Conn) SendServerSuspendPacket(reason string) error + func (self *Conn) String() string + type Message struct + func (r *Message) Payload() []byte + func (r *Message) Push(route string, data []byte) error + func (r *Message) ReqId() uint64 + func (r *Message) Response(data []byte) error + func (r *Message) Session() gira.GatewayConn + type MiddleWareInterface interface + OnSessionClose func(s *Session) + OnSessionOpen func(s *Session) + ServeMessage func(r *Message) + type Option func(gateway *Server) + func WithCheckOriginFunc(fn func(*http.Request) bool) Option + func WithDebugMode(v bool) Option + func WithDictionary(dict map[string]uint16) Option + func WithHandshakeTimeout(d time.Duration) Option + func WithHandshakeValidator(fn func([]byte) error) Option + func WithHeartbeatInterval(d time.Duration) Option + func WithIsWebsocket(enableWs bool) Option + func WithRSAPrivateKey(keyFile string) Option + func WithRecvBacklog(v int) Option + func WithRecvBuffSize(v int) Option + func WithSendBacklog(v int) Option + func WithSessionModifer(v uint64) Option + func WithTSLConfig(certificate, key string) Option + func WithWSPath(path string) Option + type Server struct + BindAddr string + Host string + Port int32 + Stat Stat + func Listen(ctx context.Context, addr string, opts ...Option) (*Server, error) + func NewConfigServer(ctx context.Context, config gira.GatewayConfig) (*Server, error) + func (server *Server) Kick(reason string) + func (server *Server) Maintain(m bool) + func (server *Server) Serve(handler gira.GatewayHandler) error + func (server *Server) Shutdown() + func (server *Server) UseMiddleware(m MiddleWareInterface) + type Session struct + func (s *Session) Bind(uid int64) error + func (s *Session) Clear() + func (s *Session) Close() error + func (s *Session) Float32(key string) float32 + func (s *Session) Float64(key string) float64 + func (s *Session) HasKey(key string) bool + func (s *Session) Id() uint64 + func (s *Session) Int(key string) int + func (s *Session) Int16(key string) int16 + func (s *Session) Int32(key string) int32 + func (s *Session) Int64(key string) int64 + func (s *Session) Int8(key string) int8 + func (s *Session) Kick(reason string) + func (s *Session) Push(route string, data []byte) error + func (s *Session) Recv(ctx context.Context) (gira.GatewayMessage, error) + func (s *Session) RemoteAddr() net.Addr + func (s *Session) Remove(key string) + func (s *Session) Response(mid uint64, data []byte) error + func (s *Session) Restore(data map[string]interface{}) + func (s *Session) SendServerDown(reason string) + func (s *Session) SendServerMaintain(reason string) + func (s *Session) SendServerResume(reason string) + func (s *Session) SendServerSuspend(reason string) + func (s *Session) Set(key string, value interface{}) + func (s *Session) SetUserData(value interface{}) + func (s *Session) State() map[string]interface{} + func (s *Session) String(key string) string + func (s *Session) UID() int64 + func (s *Session) Uint(key string) uint + func (s *Session) Uint16(key string) uint16 + func (s *Session) Uint32(key string) uint32 + func (s *Session) Uint64(key string) uint64 + func (s *Session) Uint8(key string) uint8 + func (s *Session) UserData() interface{} + func (s *Session) Value(key string) interface{} + type Stat struct + ActiveConnectionCount int64 + ActiveSessionCount int64 + CumulativeConnectionCount int64 + CumulativeSessionCount int64 + HandshakeErrorCount int64