Zinterface

package
v0.0.0-...-1f9c5ee Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientI

type ClientI interface {
	Start()
	Stop()
	Conn() ConnectionI
	GetMsgHandle() MsgHandleI
	AddRouter(uint32, RouterI)
}

type ConnectionFunc

type ConnectionFunc func(i ConnectionI)

type ConnectionI

type ConnectionI interface {
	//启动连接
	Start()
	//停止连接
	Stop()
	//获取套接字
	GetTcpConnection() *net.TCPConn
	//获取连接ID
	GetConnID() uint64
	//获取远程客户端的地址
	GetRemoteAddr() net.Addr
	GetManager() ManagerI
	//发送数据
	Send(messageId uint32, data []byte) error
	SendBuff(messageId uint32, data []byte) error
	//设置链接属性
	SetProperty(key string, value interface{})
	//获取链接属性
	GetProperty(key string) (interface{}, error)
	//移除链接属性
	RemoveProperty(key string)
}

type DataPackI

type DataPackI interface {
	GetHeadLen() uint32
	Pack(MessageI) ([]byte, error)
	UnPack([]byte) (MessageI, error)
}

type HandleFunc

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

处理连接业务的方法

type ManagerI

type ManagerI interface {
	Add(i ConnectionI) error
	Get(id uint64) (ConnectionI, error)
	GetCount() int
	UseLru(id uint64) error
	Remove(id uint64) error
	Size() int
	Clear() error
}

type MessageI

type MessageI interface {
	GetData() []byte
	GetMessageId() uint32
	GetDataLen() uint32
	SetData([]byte)
	SetMessageId(uint32)
	SetDataLen(uint32)
}

type MsgHandleI

type MsgHandleI interface {
	AddRouter(msgId uint32, r RouterI) error
	Handle(i RequestI) error
	SendMessage(r RequestI)
	Close()
}

type RequestI

type RequestI interface {
	//获取连接
	GetConnection() ConnectionI
	//获取数据
	GetData() []byte
	GetMessageID() uint32
}

type RouterI

type RouterI interface {
	//处理conn业务前中后的方法
	PreHandle(requestInterface RequestI)
	Handle(requestInterface RequestI)
	PostHandle(requestInterface RequestI)
}

type ServerI

type ServerI interface {
	Start()
	Stop()
	Serve()
	AddRouter(msgId uint32, routerInterface2 RouterI)
	GetManager() ManagerI
	CallAfterConnect(ConnectionI)
	CallBeforeConnect(ConnectionI)
	CallBeforeStop(ConnectionI)
	SetAfterConnect(ConnectionFunc)
	SetBeforeConnect(ConnectionFunc)
	SetBeforeStop(ConnectionFunc)
}

Jump to

Keyboard shortcuts

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