gate

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	WriteMsg(msg interface{})
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	Close()
	Destroy()
	UserData() interface{}
	SetUserData(data interface{})
}

type Gate

type Gate struct {
	MaxConnNum      int
	PendingWriteNum int
	MaxMsgLen       uint32
	Processor       network.Processor

	// websocket
	WSAddr      string
	HTTPTimeout time.Duration
	CertFile    string
	KeyFile     string

	// tcp
	TCPAddr   string
	LenMsgLen int

	//add by huanglin
	FunNewAgent   func(Agent)
	FunCloseAgent func(Agent)
	FuncMsgRecv   func(interface{}, Agent)
}

func NewGate

func NewGate(maxConnNum int, maxMsgLen uint32, processor network.Processor, WSAddr string,
	HTTPTimeout time.Duration, writerChanLen int) *Gate

func (*Gate) OnDestroy

func (gate *Gate) OnDestroy()

func (*Gate) Run

func (gate *Gate) Run(closeSig chan bool)

Run starts the gate service and listens for incoming connections.

func (*Gate) SetFun

func (gate *Gate) SetFun(Fun1 func(Agent), Fun2 func(Agent), Fun3 func(interface{}, Agent))

SetFun sets the functions for handling new agents, closing agents, and receiving messages.

Jump to

Keyboard shortcuts

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