cherryClient

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Connected bool

	IncomingMsgChan chan *cherryMessage.Message
	// contains filtered or unexported fields
}

Client struct

func New

func New(requestTimeout ...time.Duration) *Client

New returns a new client

func (*Client) ConnectTo

func (c *Client) ConnectTo(addr string) error

ConnectTo connects to the server at addr, for now the only supported protocol is tcp this methods blocks as it also handles the messages from the server

func (*Client) ConnectToTLS

func (c *Client) ConnectToTLS(addr string, skipVerify bool) error

ConnectToTLS connects to the server at addr using TLS, for now the only supported protocol is tcp this methods blocks as it also handles the messages from the server

func (*Client) ConnectedStatus

func (c *Client) ConnectedStatus() bool

ConnectedStatus return the connection status

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect disconnects the client

func (*Client) MsgChannel

func (c *Client) MsgChannel() chan *cherryMessage.Message

MsgChannel return the incoming message channel

func (*Client) SendNotify

func (c *Client) SendNotify(route string, data []byte) error

SendNotify sends a notify to the server

func (*Client) SendRequest

func (c *Client) SendRequest(route string, data []byte) (uint, error)

SendRequest sends a request to the server

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 IClient

type IClient interface {
	ConnectTo(addr string) error
	ConnectToTLS(addr string, skipVerify bool) error
	Disconnect()
	SendNotify(route string, data []byte) error
	SendRequest(route string, data []byte) (uint, error)
	ConnectedStatus() bool
	MsgChannel() chan *cherryMessage.Message
}

Jump to

Keyboard shortcuts

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