service

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRobot

func RegisterRobot(i IRobot)

func RegisterServerConsume

func RegisterServerConsume(i IServerConsume)

func RegisterServerEvent

func RegisterServerEvent(i IServerEvent)

func RegisterServerSubscribe

func RegisterServerSubscribe(i IServerSubscribe)

func RegisterSession

func RegisterSession(i ISession)

func RegisterTalkMessage

func RegisterTalkMessage(i ITalkMessage)

func RegisterTalkRecords

func RegisterTalkRecords(i ITalkRecords)

Types

type IRobot

type IRobot interface {
	GetRobotByUserId(ctx context.Context, userId int) (*model.Robot, error)
}

func Robot

func Robot() IRobot

type IServerConsume

type IServerConsume interface {
	// 触发回调事件
	Call(ctx context.Context, event string, data []byte)
}

func ServerConsume

func ServerConsume() IServerConsume

type IServerEvent

type IServerEvent interface {
	Call(ctx context.Context, client socket.IClient, event string, data []byte)
	// 连接成功回调事件
	OnOpen(client socket.IClient)
	// 消息回调事件
	OnMessage(client socket.IClient, message []byte)
	// 连接关闭回调事件
	OnClose(client socket.IClient, code int, text string)
}

func ServerEvent

func ServerEvent() IServerEvent

type IServerSubscribe

type IServerSubscribe interface {
	// 初始化连接
	Conn(w http.ResponseWriter, r *http.Request) error
	NewClient(uid int, conn socket.IConn) error
	// Start 启动服务
	Start(ctx context.Context, eg *errgroup.Group)
	// 注册健康上报
	SetupHealthSubscribe(ctx context.Context) error
	// 注册消息订阅
	SetupMessageSubscribe(ctx context.Context) error
}

func ServerSubscribe

func ServerSubscribe() IServerSubscribe

type ISession

type ISession interface {
	// 获取会话中UserId
	GetUid(ctx context.Context) int
}

func Session

func Session() ISession

type ITalkMessage

type ITalkMessage interface {
	// 文本消息
	SendText(ctx context.Context, uid int, req *model.TextMessageReq) error
	// 代码消息
	SendCode(ctx context.Context, uid int, req *model.CodeMessageReq) error
}

func TalkMessage

func TalkMessage() ITalkMessage

type ITalkRecords

type ITalkRecords interface {
	GetTalkRecord(ctx context.Context, recordId int) (*model.TalkRecordsItem, error)
	HandleTalkRecords(ctx context.Context, items []*model.TalkRecordsItem) ([]*model.TalkRecordsItem, error)
}

func TalkRecords

func TalkRecords() ITalkRecords

Jump to

Keyboard shortcuts

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