pomelo

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CODE_OK         = 200
	CODE_USE_ERROR  = 500
	CODE_OLD_CLIENT = 501
)

Variables

This section is empty.

Functions

func NewAgent

func NewAgent(conn network.Conn, connector *Connector) *agent

func NewAgentHandler

func NewAgentHandler(a *agent) *agentHandler

Types

type Connector

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

func NewConnector

func NewConnector(opts ...Option) *Connector

func (*Connector) GetSessionMap

func (c *Connector) GetSessionMap() *connector.SessionMap

func (*Connector) OnDestroy

func (c *Connector) OnDestroy()

func (*Connector) OnInit

func (c *Connector) OnInit(server component.ServerImpl)

func (*Connector) OnRun

func (c *Connector) OnRun(closeSig chan bool)

func (*Connector) Route

func (c *Connector) Route(f rpc.CustomerRoute)

func (*Connector) SetConnectionListener

func (c *Connector) SetConnectionListener(conn connector.Connection)

func (*Connector) SetHandlerFilter

func (c *Connector) SetHandlerFilter(f filter.Filter)

Set a filter for client handler

type Option

type Option func(*Options)

func CertFile

func CertFile(f string) Option

Cert file for https

func HTTPTimeout

func HTTPTimeout(t time.Duration) Option

Timeout for http handshake. Default is 10s

func HeartbeatTimeout

func HeartbeatTimeout(t time.Duration) Option

Heartbeat timeout. Default is 10s. Disconnect if after 2*t

func KeyFile

func KeyFile(f string) Option

Key file for https

func LenMsgLen

func LenMsgLen(num int) Option

Length of message length. Useful for tcp. Option is 1,2,4. Default is 2

func LittleEndian

func LittleEndian(littleEndian bool) Option

Useful for tcp. Default is false

func MaxConnNum

func MaxConnNum(num int) Option

Max connections support. Default is 20000

func MaxMsgLen

func MaxMsgLen(length uint32) Option

Max message length. If a message exceeds the limit, the connection sends a close message to the peer. Default is 4096

func TCPAddr

func TCPAddr(addr string) Option

Address of tcp server as "host:port"

func WSAddr

func WSAddr(addr string) Option

Address of websocket server as "host:port"

type Options

type Options struct {
	MaxConnNum       int
	MaxMsgLen        uint32
	HeartbeatTimeout time.Duration

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

	// tcp
	TCPAddr      string
	LenMsgLen    int
	LittleEndian bool
}

Jump to

Keyboard shortcuts

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