Documentation ¶
Index ¶
- Variables
- func Initialize(ctx context.Context, eg *errgroup.Group, fn func(name string))
- func NewClient(conn IConn, option *ClientOption, event IEvent) error
- type AckBuffer
- type AckBufferContent
- type Channel
- type Client
- type ClientOption
- type ClientResponse
- type CloseEvent
- type DestroyEvent
- type Event
- type EventOption
- type IChannel
- type IClient
- type IConn
- type IEvent
- type IStorage
- type IdGenerator
- type Message
- type MessageEvent
- type OpenEvent
- type SenderContent
- func (s *SenderContent) IsBroadcast() bool
- func (s *SenderContent) SetAck(value bool) *SenderContent
- func (s *SenderContent) SetBroadcast(value bool) *SenderContent
- func (s *SenderContent) SetExclude(cid ...int64) *SenderContent
- func (s *SenderContent) SetMessage(event string, content any) *SenderContent
- func (s *SenderContent) SetReceive(cid ...int64) *SenderContent
- type SnowflakeGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var Session *session
客户端管理实例
Functions ¶
Types ¶
type AckBuffer ¶
type AckBuffer struct {
// contains filtered or unexported fields
}
AckBuffer Ack 确认缓冲区
type AckBufferContent ¶
type AckBufferContent struct {
// contains filtered or unexported fields
}
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
渠道管理(多渠道划分, 实现不同业务之间隔离)
func NewChannel ¶
func NewChannel(name string, outChan chan *SenderContent) *Channel
type ClientOption ¶
type ClientOption struct { Uid int // 用户识别ID Channel IChannel // 渠道信息 Storage IStorage // 自定义缓存组件, 用于绑定用户与客户端的关系 IdGenerator IdGenerator // 客户端ID生成器(唯一ID), 默认使用雪花算法 Buffer int // 缓冲区大小根据业务, 自行调整 }
type ClientResponse ¶
type CloseEvent ¶
type DestroyEvent ¶
type DestroyEvent func(client IClient)
type EventOption ¶
type EventOption func(event *Event)
type IEvent ¶
type IEvent interface { Open(client IClient) Message(client IClient, data []byte) Close(client IClient, code int, text string) Destroy(client IClient) }
func NewEvent ¶
func NewEvent(opts ...EventOption) IEvent
type IdGenerator ¶
type IdGenerator interface { // 获取自增ID IdGen() int64 }
type MessageEvent ¶
type SenderContent ¶
type SenderContent struct { IsAck bool // contains filtered or unexported fields }
推送的消息
func NewSenderContent ¶
func NewSenderContent() *SenderContent
func (*SenderContent) SetAck ¶
func (s *SenderContent) SetAck(value bool) *SenderContent
func (*SenderContent) SetBroadcast ¶
func (s *SenderContent) SetBroadcast(value bool) *SenderContent
设置广播推送
func (*SenderContent) SetExclude ¶
func (s *SenderContent) SetExclude(cid ...int64) *SenderContent
设置广播推送中需要过滤的客户端
func (*SenderContent) SetMessage ¶
func (s *SenderContent) SetMessage(event string, content any) *SenderContent
func (*SenderContent) SetReceive ¶
func (s *SenderContent) SetReceive(cid ...int64) *SenderContent
设置推送客户端
type SnowflakeGenerator ¶
type SnowflakeGenerator struct {
// contains filtered or unexported fields
}
func (*SnowflakeGenerator) IdGen ¶
func (s *SnowflakeGenerator) IdGen() int64
Source Files ¶
Click to show internal directories.
Click to hide internal directories.