ziface

package
v0.0.0-...-d072998 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IConnManger

type IConnManger interface {
	Add(conn IConnection)
	Remove(conn IConnection)
	Get(connID uint32) (IConnection, error)
	Len() int
	ClearConn()
}

连接管理模块

type IConnection

type IConnection interface {
	Start()
	Stop()
	GetTCPConnection() *net.TCPConn
	GetConnID() uint32
	RemoteAddr() net.Addr
	SendMsg(msgId uint32, data []byte) error
}

type IMessage

type IMessage interface {
	//TLV 格式数据包
	GetDataLen() uint32
	GetMsgID() uint32
	GetData() []byte

	SetMsgID(uint32)
	SetData([]byte)
	SetDataLen(uint32)
}

type IMsgHandle

type IMsgHandle interface {
	DoMsgHandler(request IRequest)
	AddRoute(msgId uint32, route IRoute)
	StartWorkerPool()
	SendMsgToTaskQueue(request IRequest)
}

type IRequest

type IRequest interface {
	GetConnection() IConnection
	GetData() []byte
	GetMsgID() uint32
}

type IRoute

type IRoute interface {
	PreHandler(request IRequest)
	Handler(request IRequest)
	PostHandler(request IRequest)
}

type IServer

type IServer interface {
	Start()
	Stop()
	Server()
	AddRoute(msgId uint32, route IRoute)
	GetConnMgr() IConnManger
	// 设置该Server的连接创建时Hook函数
	SetOnConnStart(func(IConnection))
	// 设置该Server的连接断开时Hook函数
	SetOnConnStop(func(IConnection))
	// 调用连接OnConnStart Hook函数
	CallOnConnStart(IConnection)
	// 调用连接OnConnStop Hook函数
	CallOnConnStop(IConnection)
}

Jump to

Keyboard shortcuts

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