server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateConnID

func GenerateConnID() int32

生成UUIDV4的murmur3算法int32 hash值

Types

type IConnGroupMagage added in v0.1.1

type IConnGroupMagage interface {
	AddGroup(g connmanage.GroupHook) error
	RemoveGroup(g connmanage.GroupHook) error
	Group(g connmanage.GroupHook) (map[int32]struct{}, error)
	AddConnToGroup(g connmanage.GroupHook, conn int32) error
	RemoveConnFromGroup(g connmanage.GroupHook, conn int32) error
	ClearGroup(g connmanage.GroupHook) error
}

func NewConnGroup added in v0.1.1

func NewConnGroup() IConnGroupMagage

type IRouterManage

type IRouterManage interface {
	RegisterRoute(id int32, route routermanage.RouterHandle) error
	HandleMessage(routerid, connid, msgid int32, parameter []byte) error
}

func NewRouterManage

func NewRouterManage(name string, store store.ITCPStore) IRouterManage

type ITCPConnManage

type ITCPConnManage interface {
	AddConn(conn connect.ITCPConn) error
	RemoveConn(conn connect.ITCPConn, err error) error
	FindConn(id int32) (connect.ITCPConn, error)
	CheckHealths(context.Context)
	SetHook(connect.Hook)
	Hook() connect.Hook
	AllConn() map[int32]connect.ITCPConn
	OutTimeOption(string) int64
	ReadBuffer() int32
	WriteBuffer() int32
}

IConnManage 接口用于管理连接。

func NewConnManage

func NewConnManage(conntype string, store store.ITCPStore, hook connect.Hook, opt ...connmanage.ConnManagerOption) ITCPConnManage

NewConnManage 创建一个新的连接管理器。

type ServerOption

type ServerOption func(options *serveroptions) error

ServerOption 服务器选项

func WithIP

func WithIP(ip string) ServerOption

ip:ipv4地址

func WithPort

func WithPort(port int64) ServerOption

port:端口号

func WithServerName

func WithServerName(servername string) ServerOption

servername:服务器名称

type TCPServer

type TCPServer struct {
	// contains filtered or unexported fields
}

func NewTCPServer

func NewTCPServer(connManager ITCPConnManage, router IRouterManage, opt ...ServerOption) *TCPServer

NewTCPServer 创建一个tcp服务器 IConnManage:连接管理器实例,IRouterManage:路由管理实例 ,ServerOption:服务器选项

func (*TCPServer) Start

func (s *TCPServer) Start() error

启动服务

func (*TCPServer) Stop

func (s *TCPServer) Stop() error

停止服务

Jump to

Keyboard shortcuts

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