tcpmodule

package
v2.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) GetId

func (slf *Client) GetId() string

func (*Client) OnClose

func (slf *Client) OnClose()

func (*Client) Run

func (slf *Client) Run()

type TcpCfg

type TcpCfg struct {
	ListenAddr          string        //监听地址
	MaxConnNum          int           //最大连接数
	PendingWriteNum     int           //写channel最大消息数量
	LittleEndian        bool          //是否小端序
	LenMsgLen           int           //消息头占用byte数量,只能是1byte,2byte,4byte。如果是4byte,意味着消息最大可以是math.MaxUint32(4GB)
	MinMsgLen           uint32        //最小消息长度
	MaxMsgLen           uint32        //最大消息长度,超过判定不合法,断开连接
	ReadDeadlineSecond  time.Duration //读超时
	WriteDeadlineSecond time.Duration //写超时
}

type TcpModule

type TcpModule struct {
	service.Module
	// contains filtered or unexported fields
}

func (*TcpModule) Close

func (tm *TcpModule) Close(clientId string)

func (*TcpModule) GetClientIp

func (tm *TcpModule) GetClientIp(clientId string) string

func (*TcpModule) GetConnNum

func (tm *TcpModule) GetConnNum() int

func (*TcpModule) GetProcessor

func (tm *TcpModule) GetProcessor() processor.IRawProcessor

func (*TcpModule) Init

func (tm *TcpModule) Init(tcpCfg *TcpCfg, process processor.IRawProcessor)

func (*TcpModule) NewClient

func (tm *TcpModule) NewClient(conn network.Conn) network.Agent

func (*TcpModule) OnInit

func (tm *TcpModule) OnInit() error

func (*TcpModule) SendMsg

func (tm *TcpModule) SendMsg(clientId string, msg interface{}) error

func (*TcpModule) SendRawMsg

func (tm *TcpModule) SendRawMsg(clientId string, msg []byte) error

func (*TcpModule) Start

func (tm *TcpModule) Start() error

type TcpPack

type TcpPack struct {
	Type                TcpPackType //0表示连接 1表示断开 2表示数据
	ClientId            string
	Data                interface{}
	RecyclerReaderBytes func(data []byte)
}

type TcpPackType

type TcpPackType int8
const (
	TPTConnected    TcpPackType = 0
	TPTDisConnected TcpPackType = 1
	TPTPack         TcpPackType = 2
	TPTUnknownPack  TcpPackType = 3
)

Jump to

Keyboard shortcuts

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