cherryClient

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionFn added in v1.1.28

type ActionFn func() error

type Client

type Client struct {
	TagName string // 客户标识
	// contains filtered or unexported fields
}

Client struct

func New

func New(opts ...Option) *Client

New returns a new client

func (*Client) AddAction added in v1.1.28

func (p *Client) AddAction(actionFn ActionFn)

func (*Client) Codec added in v1.1.27

func (p *Client) Codec() cfacade.IPacketCodec

func (*Client) ConnectToTCP added in v1.1.27

func (p *Client) ConnectToTCP(addr string, tlsConfig ...*tls.Config) error

func (*Client) ConnectToWS added in v1.1.27

func (p *Client) ConnectToWS(addr string, path string, tlsConfig ...*tls.Config) error

func (*Client) Disconnect

func (p *Client) Disconnect()

func (*Client) HandshakeData added in v1.1.29

func (p *Client) HandshakeData() *HandshakeData

func (*Client) IsConnected added in v1.1.27

func (p *Client) IsConnected() bool

IsConnected return the connection status

func (*Client) Notify added in v1.1.27

func (p *Client) Notify(route string, val interface{}) error

Notify sends a notify to the server

func (*Client) On added in v1.1.27

func (p *Client) On(route string, fn OnMessageFn)

On listener route

func (*Client) Request added in v1.1.27

func (p *Client) Request(route string, val interface{}) (*cmsg.Message, error)

func (*Client) Send added in v1.1.27

func (p *Client) Send(msgType cmsg.Type, route string, val interface{}) (uint, error)

Send the message to the server

func (*Client) SendRaw added in v1.1.28

func (p *Client) SendRaw(typ cpacket.Type, data []byte) error

func (*Client) Serializer added in v1.1.27

func (p *Client) Serializer() cfacade.ISerializer

type HandshakeData

type HandshakeData struct {
	Code int          `json:"code"`
	Sys  HandshakeSys `json:"sys"`
}

HandshakeData struct

type HandshakeSys

type HandshakeSys struct {
	Dict       map[string]uint16 `json:"dict"`
	Heartbeat  int               `json:"heartbeat"`
	Serializer string            `json:"serializer"`
}

HandshakeSys struct

type OnMessageFn added in v1.1.27

type OnMessageFn func(msg *cmsg.Message)

type Option added in v1.1.27

type Option func(options *options)

func WithErrorBreak added in v1.1.28

func WithErrorBreak(isBreak bool) Option

func WithHandshake added in v1.1.27

func WithHandshake(handshake string) Option

func WithHeartbeat added in v1.1.27

func WithHeartbeat(heartBeat int) Option

func WithPacketCodec added in v1.1.27

func WithPacketCodec(codec cfacade.IPacketCodec) Option

func WithRequestTimeout added in v1.1.27

func WithRequestTimeout(requestTimeout time.Duration) Option

func WithSerializer added in v1.1.27

func WithSerializer(serializer cfacade.ISerializer) Option

type RequestContext added in v1.2.10

type RequestContext struct {
	*time.Ticker
	Chan chan *cmsg.Message
}

func NewRequestContext added in v1.2.10

func NewRequestContext(t time.Duration) RequestContext

func (*RequestContext) Close added in v1.2.10

func (p *RequestContext) Close()

Jump to

Keyboard shortcuts

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