tcpface

package
v2.10.18 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 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 IConnHandler

type IConnHandler func(server IServer, conn net.Conn, connId int) IConnection

type IConnManager

type IConnManager interface {
	Add(conn IConnection)                //添加链接
	Remove(conn IConnection)             //删除连接
	Get(connID int) (IConnection, error) //利用ConnID获取链接
	Len() int                            //获取当前连接
	ClearConn()                          //删除并停止所有链接
}

type IConnection

type IConnection interface {
	GetConn() net.Conn
	// GetConnID 获取当前连接ID
	GetConnID() int
	// RemoteAddr 获取远程客户端地址信息
	RemoteAddr() net.Addr
	Close() error
	StartWriter()
}

IConnection 定义连接接口

type IMsgHandle

type IMsgHandle interface {
	StartWorkerPool() //启动worker工作池
	Handle(iConn IConnection)
}

IMsgHandle 消息管理抽象层

type IServer

type IServer interface {
	// Start 启动服务器方法
	Start()
	// Stop 停止服务器方法
	Stop()
	// Serve 开启业务服务方法
	Serve()
	// GetConnMgr 得到链接管理
	GetConnMgr() IConnManager
	// SetOnConnStart 设置该Server的连接创建时Hook函数
	SetOnConnStart(func(IConnection))
	// SetOnConnStop 设置该Server的连接断开时的Hook函数
	SetOnConnStop(func(IConnection))
	// CallOnConnStart 调用连接OnConnStart Hook函数
	CallOnConnStart(conn IConnection)
	// CallOnConnStop 调用连接OnConnStop Hook函数
	CallOnConnStop(conn IConnection)
	// GetMsgHandler 获取GetMsgHandler
	GetMsgHandler() IMsgHandle
	// GetServerID 获取serverId
	GetServerID() string
}

IServer 定义服务器接口

Jump to

Keyboard shortcuts

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