pomelo

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(data []byte)

Callback represents the callback type which will be called when the correspond events is occurred.

type Connector

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

Connector is a Pomelo client

func NewConnector

func NewConnector() *Connector

func (*Connector) Close

func (c *Connector) Close()

Close the connection, and shutdown the benchmark

func (*Connector) Connected

func (c *Connector) Connected(cb func())

Connected 连接之后 cb

func (*Connector) IsClosed

func (c *Connector) IsClosed() bool

IsClosed check the connection is closed

func (*Connector) Notify

func (c *Connector) Notify(route string, data []byte) error

Notify send a notification to server

func (*Connector) On

func (c *Connector) On(event string, callback Callback)

On add the callback for the event

func (*Connector) Request

func (c *Connector) Request(route string, data []byte, callback Callback) error

Request send a request to server and register a callback for the response

func (*Connector) Run

func (c *Connector) Run(addr string) error

Run 启动连接

func (*Connector) SetHandshakeAckData

func (c *Connector) SetHandshakeAckData(handshakeAck interface{}) error

SetHandshakeAckData 设置握手ACK数据

func (*Connector) SetHandshakeData

func (c *Connector) SetHandshakeData(handshake interface{}) error

SetHandshakeData 设置握手协议数据

func (*Connector) SetHandshakeRespDo

func (c *Connector) SetHandshakeRespDo(do HandShakeRespDo)

func (*Connector) SetHeartBeatData

func (c *Connector) SetHeartBeatData(heartbeat interface{}) error

SetHeartBeatData 设置心跳包数据

type HandShakeRespDo

type HandShakeRespDo interface {
	Unmarshal(data []byte) error
	Success() bool
	HeartbeatSec() int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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