cherryClient

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 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

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

func (p *Client) AddAction(actionFn ActionFn)

func (*Client) Codec

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

func (*Client) ConnectToTCP

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

func (*Client) ConnectToWS

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

func (*Client) Disconnect

func (p *Client) Disconnect()

func (*Client) HandshakeData

func (p *Client) HandshakeData() *HandshakeData

func (*Client) IsConnected

func (p *Client) IsConnected() bool

IsConnected return the connection status

func (*Client) Notify

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

Notify sends a notify to the server

func (*Client) On

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

On listener route

func (*Client) Request

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

func (*Client) Send

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

Send send the message to the server

func (*Client) SendRaw

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

func (*Client) Serializer

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

type OnMessageFn func(msg *cmsg.Message)

type Option

type Option func(options *options)

func WithErrorBreak

func WithErrorBreak(isBreak bool) Option

func WithHandshake

func WithHandshake(handshake string) Option

func WithHeartbeat

func WithHeartbeat(heartBeat int) Option

func WithPacketCodec

func WithPacketCodec(codec cfacade.IPacketCodec) Option

func WithRequestTimeout

func WithRequestTimeout(requestTimeout time.Duration) Option

func WithSerializer

func WithSerializer(serializer cfacade.ISerializer) Option

Jump to

Keyboard shortcuts

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