client

package
v0.0.0-...-7a3d942 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 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 Client

type Client struct {
	ConnCloseCh chan struct{}
	// contains filtered or unexported fields
}

Client ...

func New

func New(cfg Config) Client

New creates new client

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect connects to the specified host with specified port

func (Client) Ping

func (c Client) Ping(ctx context.Context) (uint16, error)

Ping sends PING packet, returns ID of ping

func (Client) ReadLoop

func (c Client) ReadLoop()

ReadLoop reads all data from connection in loop

func (Client) Send

func (c Client) Send(data []byte) error

Send sends a data

func (Client) SendWithResponse

func (c Client) SendWithResponse(ctx context.Context, data []byte) (packets.SendResponsePayload, error)

SendWithResponse sends a data and waits for response

type Config

type Config struct {
	// ClientID
	//
	// Required
	ClientID string

	// Ed25519 Public key
	//
	// Required
	PublicKey ed25519.PublicKey

	// Ed25519 Private key
	//
	// Required
	PrivateKey ed25519.PrivateKey

	// Hostname of where broker should listen
	//
	// Default: "localhost"
	Hostname string

	// Port of where broker should listen
	//
	// Default: "997"
	Port uint32
}

Config ...

func (Config) Parse

func (cfg Config) Parse() (Config, error)

Parse parses options and set defaults

Jump to

Keyboard shortcuts

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