ziface

package
v0.0.0-...-ee6b5e2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 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 HandleFunc

type HandleFunc func(*net.TCPConn, []byte, int) error

定义一个处理链接业务的方法

type IConnection

type IConnection interface {
	//启动链接,让当前的链接准备开始工作
	Start()
	//停止链接,结束当前链接的工作
	Stop()
	//获取当前链接的绑定socket conn
	GetTCPConnection() *net.TCPConn
	//获取当前链接模块的链接ID
	GetConnID() uint32
	//获取远程客户端的TCP状态 IP port
	GetRemoteAddr() net.Addr
	//发送数据,将数据发送给远程的客户端
	Send(data []byte) error
}

定义连接模块的抽象层

type IRequest

type IRequest interface {
	//得到当前链接
	GetConnection() IConnection
	//得到请求的消息数据
	GetData() []byte
}

type IRouter

type IRouter interface {
	//处理之前的方法
	BeforeHandle(request IRequest)
	//处理时的方法
	Handle(request IRequest)
	//处理后的方法
	AfterHandle(request IRequest)
}

路由的抽象接口,

type IServer

type IServer interface {
	//启动服务器
	Start()
	//停止服务器
	Stop()
	//运行服务器
	Serve()
	//添加路由
	AddRouter(router IRouter)
}

定义一个服务器接口

Jump to

Keyboard shortcuts

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