tcpgnet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Conn) Close

func (conn *Conn) Close()

Close 关闭

func (*Conn) Init

func (conn *Conn) Init(c gnet.Conn)

Init 初始化

func (*Conn) LocalAddr

func (conn *Conn) LocalAddr() net.Addr

LocalAddr 本地地址

func (*Conn) RemoteAddr

func (conn *Conn) RemoteAddr() net.Addr

RemoteAddr 远程地址

func (*Conn) Run

func (conn *Conn) Run()

Run 主逻辑

func (*Conn) Write

func (conn *Conn) Write(b []byte) (n int, err error)

Write 发送数据

type Server

type Server struct {
	*gnet.EventServer
	// contains filtered or unexported fields
}

Server TCP GNet 服务器

func (*Server) Close

func (server *Server) Close()

Close 关闭TCP监听

func (*Server) GetConnNum

func (server *Server) GetConnNum() (num int)

GetConnNum 获取所有连接的数量

func (*Server) OnClosed

func (server *Server) OnClosed(c gnet.Conn, err error) (action gnet.Action)

OnClosed 当连接关闭时调用

func (*Server) OnOpened

func (server *Server) OnOpened(c gnet.Conn) (out []byte, action gnet.Action)

OnOpened 当有新连接建立时调用

func (*Server) React

func (server *Server) React(frame []byte, c gnet.Conn) (out []byte, action gnet.Action)

React 当有消息收到时调用

func (*Server) Run

func (server *Server) Run()

Run 执行服务端逻辑

func (*Server) Start

func (server *Server) Start(address string, newAgent core.GetAgent, opts ...core.ServerOption) error

Start 开始tcp监听

func (*Server) Tick

func (server *Server) Tick() (delay time.Duration, action gnet.Action)

Tick 每隔一段时间调用

Jump to

Keyboard shortcuts

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