client

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFetcher added in v0.3.0

type AddressFetcher func() (string, error)

type Client

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

func NewClient

func NewClient(opts *Options) (c *Client, err error)

func (*Client) Ack

func (c *Client) Ack(event string, v interface{}, r interface{}) (err error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Emit

func (c *Client) Emit(event string, v interface{}) (err error)

func (*Client) FetchAddress added in v0.3.0

func (c *Client) FetchAddress() (err error)

func (*Client) IsClosed

func (c *Client) IsClosed() bool

func (*Client) MustStart

func (c *Client) MustStart()

func (*Client) On

func (c *Client) On(e string, fn EventHandler)

func (*Client) RemoteAddr

func (c *Client) RemoteAddr() string

func (*Client) Start

func (c *Client) Start() error

type Context

type Context interface {
	IsClosed() bool
	Close()

	Emit(event string, v interface{}) error
	Ack(event string, v interface{}, r interface{}) error

	Content() []byte
	Packet() air.Packet
	Bind(v interface{}) error

	Reply(v interface{}) error

	Logger() air.Logger
}

type EventHandler

type EventHandler func(c Context) error

type Options

type Options struct {
	// common
	WorkId                 uint16
	AddressFetcher         AddressFetcher
	PacketSendChanLimit    uint32
	PacketReceiveChanLimit uint32
	MessageTimeout         time.Duration
	Codec                  air.Codec
	Logger                 air.Logger

	// only for client
	HeartbeatInterval time.Duration
	ReconnectInterval time.Duration
	ReconnectLimit    uint32
	Reconnect         bool
}

func DefaultOptions

func DefaultOptions() *Options

Jump to

Keyboard shortcuts

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