tcpLib

package
v0.0.0-...-bdb8b81 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHeartBeatIntervalMs = 5 * 1000 // 60s
)

Variables

This section is empty.

Functions

func DialTcpServer

func DialTcpServer(name, addr string) (*TcpClient, Result)

Types

type ClientServerMsg

type ClientServerMsg struct {
	Session *TcpSession
	netType.NetMsg
}

func NewClientServerMsg

func NewClientServerMsg(sessionPtr *TcpSession, msg *netType.NetMsg) *ClientServerMsg

type TcpClient

type TcpClient struct {
	Name string
	// contains filtered or unexported fields
}

func (*TcpClient) Close

func (this *TcpClient) Close()

func (*TcpClient) GetReceiveMsgChan

func (this *TcpClient) GetReceiveMsgChan() chan *ClientServerMsg

func (*TcpClient) SendMsg

func (this *TcpClient) SendMsg(data []byte)

send msg to server

func (*TcpClient) SendPBMsg

func (this *TcpClient) SendPBMsg(msg proto.Message) Result

type TcpServer

type TcpServer struct {
	ReceiveMsgChan    chan *ClientServerMsg // Out message channel needs to be referenced by the outside world
	AcceptSessionChan chan *TcpSession      // Accept session channel needs to be referenced by the outside world
	// contains filtered or unexported fields
}

func NewTcpServer

func NewTcpServer(addr string) *TcpServer

func (*TcpServer) Start

func (this *TcpServer) Start() Result

func (*TcpServer) Stop

func (this *TcpServer) Stop()

type TcpSession

type TcpSession struct {
	ID uint32

	ReceiveMsgChan chan *ClientServerMsg // Referenced external out message channel
	// contains filtered or unexported fields
}

func (*TcpSession) HeartBeat

func (this *TcpSession) HeartBeat()

func (*TcpSession) IsActive

func (this *TcpSession) IsActive() bool

func (*TcpSession) OnReceiveHeartBeat

func (this *TcpSession) OnReceiveHeartBeat()

func (*TcpSession) SendHeartBeatMsg

func (this *TcpSession) SendHeartBeatMsg()

func (*TcpSession) SendMsg

func (this *TcpSession) SendMsg(data []byte)

func (*TcpSession) Start

func (this *TcpSession) Start()

func (*TcpSession) Stop

func (this *TcpSession) Stop()

Jump to

Keyboard shortcuts

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