cherryConnector

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOrigin

func CheckOrigin(_ *http.Request) bool

CheckOrigin 请求检查函数 防止跨站请求伪造 true则不检查

func GetNetListener

func GetNetListener(address, certFile, keyFile string) (net.Listener, error)

Types

type BlackListFn

type BlackListFn func(list []string)

type CheckClientFn

type CheckClientFn func(typ string, version string) bool

type Connection

type Connection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

connCount count

func (*Connection) Add

func (c *Connection) Add(info *LoginRecord)

func (*Connection) DecreaseConn

func (c *Connection) DecreaseConn()

func (*Connection) IncreaseConn

func (c *Connection) IncreaseConn()

func (*Connection) List

func (c *Connection) List() (connCount int32, loginCount int32, loginRecords map[cherryInterfaces.UID]*LoginRecord)

func (*Connection) Remove

func (c *Connection) Remove(uid cherryInterfaces.UID)

type LoginRecord

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

type PomeloComponent

type PomeloComponent struct {
	cherryInterfaces.BaseComponent
	PomeloComponentOptions
	// contains filtered or unexported fields
}

func NewPomelo

func NewPomelo() *PomeloComponent

func NewPomeloWithOpts

func NewPomeloWithOpts(opts PomeloComponentOptions) *PomeloComponent

func (*PomeloComponent) AfterInit

func (p *PomeloComponent) AfterInit()

func (*PomeloComponent) Init

func (p *PomeloComponent) Init()

func (*PomeloComponent) Name

func (p *PomeloComponent) Name() string

func (*PomeloComponent) Stop

func (p *PomeloComponent) Stop()

type PomeloComponentOptions

type PomeloComponentOptions struct {
	Connector       cherryInterfaces.IConnector
	ConnectListener cherryInterfaces.IConnectListener
	PacketEncode    cherryInterfaces.PacketEncoder
	PacketDecode    cherryInterfaces.PacketDecoder
	Serializer      cherryInterfaces.ISerializer
	SessionOnClosed cherryInterfaces.SessionListener
	SessionOnError  cherryInterfaces.SessionListener

	BlackListFunc       BlackListFn
	BlackList           []string
	ForwardMessage      bool
	Heartbeat           int
	DisconnectOnTimeout bool
	UseDict             bool
	UseProtobuf         bool
	UseCrypto           bool
	UseHostFilter       bool
	CheckClient         CheckClientFn
	DataCompression     bool
}

type SimpleComponent

type SimpleComponent struct {
	cherryInterfaces.BaseComponent
	SimpleComponentOptions
	// contains filtered or unexported fields
}

func (*SimpleComponent) AfterInit

func (t *SimpleComponent) AfterInit()

func (*SimpleComponent) Init

func (t *SimpleComponent) Init()

func (*SimpleComponent) Name

func (t *SimpleComponent) Name() string

type SimpleComponentOptions

type SimpleComponentOptions struct {
	Connector      cherryInterfaces.IConnector
	Encode         cherryInterfaces.PacketEncoder
	Decode         cherryInterfaces.PacketDecoder
	Serializer     cherryInterfaces.ISerializer
	ForwardMessage bool
	Heartbeat      int
}

type TCPConnector

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

func NewTCPConnector

func NewTCPConnector(address string) *TCPConnector

func NewTCPConnectorLTS

func NewTCPConnectorLTS(address, certFile, keyFile string) *TCPConnector

func (*TCPConnector) OnConnect

func (t *TCPConnector) OnConnect(listener cherryInterfaces.IConnectListener)

func (*TCPConnector) Start

func (t *TCPConnector) Start()

Startup

func (*TCPConnector) Stop

func (t *TCPConnector) Stop()

Shutdown stops the acceptor

type WebSocketConnector

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

func NewWSConnectorLTS

func NewWSConnectorLTS(address, certFile, keyFile string) *WebSocketConnector

func NewWebSocketConnector

func NewWebSocketConnector(address string) *WebSocketConnector

func (*WebSocketConnector) OnConnect

func (w *WebSocketConnector) OnConnect(listener cherryInterfaces.IConnectListener)

func (*WebSocketConnector) ServeHTTP

func (w *WebSocketConnector) ServeHTTP(rw http.ResponseWriter, r *http.Request)

ServerHTTP server.Handler

func (*WebSocketConnector) Start

func (w *WebSocketConnector) Start()

ListenAndServe listens and serve in the specified addr

func (*WebSocketConnector) Stop

func (w *WebSocketConnector) Stop()

Jump to

Keyboard shortcuts

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