data

package
v0.0.0-...-cefb499 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	biz.IManage
	biz.ITopic
	biz.IHandle
	Logger *zap.Logger
	// contains filtered or unexported fields
}

Admin 最终用户拿到的实体对象

func NewAdmin

func NewAdmin(m biz.IManage, t biz.ITopic, h biz.IHandle, z *zap.Logger) *Admin

func (*Admin) AddCheckFunc

func (a *Admin) AddCheckFunc(funcName string, f func(interface{}) (string, bool))

AddCheckFunc 添加校验方法

func (*Admin) CheckWs

func (a *Admin) CheckWs(funcName string, option interface{}) (string, bool)

CheckWs ws校验

func (*Admin) HandlerMes

func (a *Admin) HandlerMes(msg biz.IMessage) bool

HandlerMes 处理message 分发客户端流程

func (*Admin) HandlerWS

func (a *Admin) HandlerWS(funcName string, options *websocket.AcceptOptions) func(c *gin.Context)

HandlerWS 注册web路由

func (*Admin) Register

func (a *Admin) Register(key string) biz.IClient

Register 注册

func (*Admin) RegisteredMsgHandler

func (a *Admin) RegisteredMsgHandler(t int32, handlerFunc biz.TypeHandlerFunc) bool

RegisteredMsgHandler 注册处理消息

func (*Admin) SendMsg

func (a *Admin) SendMsg(funcName string) func(c *gin.Context)

SendMsg 发送消息

func (*Admin) UnRegister

func (a *Admin) UnRegister(key string)

UnRegister 注销

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, buf int64) *Client

NewClient 返回实例化

func (*Client) GetCtx

func (c *Client) GetCtx() context.Context

GetCtx 获取ctx

func (*Client) MsgChan

func (c *Client) MsgChan() <-chan biz.IMessage

MsgChan 返回channel

func (*Client) SendMes

func (c *Client) SendMes(msg biz.IMessage) bool

SendMes 发送消息(非阻塞,如果已经满了则快速失败)

func (*Client) SetCtx

func (c *Client) SetCtx(ctx context.Context)

SetCtx 设置ctx

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown 关闭

type Handle

type Handle struct {
	// lock: 读写锁 避免并发
	sync.Mutex
	// contains filtered or unexported fields
}

func NewHandle

func NewHandle() *Handle

func (*Handle) GetHandler

func (h *Handle) GetHandler(i int32) (biz.TypeHandlerFunc, bool)

GetHandler 获取注册函数

func (*Handle) Register

func (h *Handle) Register(i int32, handlerFunc biz.TypeHandlerFunc) bool

Register 注册

type Manage

type Manage struct {
	// contains filtered or unexported fields
}

Manage 管理所有客户端

func NewManage

func NewManage(buf int64) *Manage

NewManage 新建 Manage对象

func (*Manage) FindClient

func (m *Manage) FindClient(key string) (biz.IClient, bool)

FindClient 查找客户端

func (*Manage) FindClients

func (m *Manage) FindClients(key ...string) []biz.IClient

FindClients 批量查找客户端用户

func (*Manage) GetAll

func (m *Manage) GetAll() []biz.IClient

GetAll 查找所有客户端

func (*Manage) Register

func (m *Manage) Register(key string) biz.IClient

Register 注册

func (*Manage) UnRegister

func (m *Manage) UnRegister(key string)

UnRegister 注销

type Message

type Message struct {
	Type int32  `json:"type"`
	Time int64  `json:"time"`
	From string `json:"From"`
	To   string `json:"to" binding:"required"`
	Data []byte `json:"data" binding:"required"`
}

func (*Message) GetTo

func (m *Message) GetTo() string

GetTo 获取接收人

func (*Message) GetType

func (m *Message) GetType() int32

GetType 获取状态信息

func (*Message) Marshal

func (m *Message) Marshal() ([]byte, error)

func (*Message) Unmarshal

func (m *Message) Unmarshal(data []byte) error

type Topic

type Topic struct {
	// lock: 读写锁 避免并发
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTopic

func NewTopic() *Topic

func (*Topic) CreateTopic

func (t *Topic) CreateTopic(topic string)

CreateTopic 创建topic

func (*Topic) DeleteTopic

func (t *Topic) DeleteTopic(topic string)

DeleteTopic 删除topic

func (*Topic) GetTopicList

func (t *Topic) GetTopicList(topic string) []string

GetTopicList 获取订阅topic的用户

func (*Topic) Subscribe

func (t *Topic) Subscribe(topic, key string) bool

Subscribe 订阅

func (*Topic) UnSubscribe

func (t *Topic) UnSubscribe(topic, key string) bool

UnSubscribe 退订

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL