client

package
v0.0.0-...-a01428d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: Apache-2.0 Imports: 12 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 {
	WillTopic   string
	WillMessage []byte
	WillQos     byte
	WillRetain  bool
	Keepalive   uint16 //second
	// contains filtered or unexported fields
}

func NewClient

func NewClient(id string, mgr session.SessionMgr) *Client

func (*Client) Connect

func (this *Client) Connect(proto, addr string) (token session.Token, err error)

连接服务器 addr格式: [username][:password]@ip[:port]

func (*Client) Disconnect

func (this *Client) Disconnect() (err error)

func (*Client) GetID

func (this *Client) GetID() string

func (*Client) GetKeepalive

func (this *Client) GetKeepalive() uint16

func (*Client) Publish

func (this *Client) Publish(topic string, body []byte, qos byte, retain bool) (token session.Token, err error)

发布消息

func (*Client) SetKeepalive

func (this *Client) SetKeepalive(keepalive uint16)

func (*Client) SetOnDisconnected

func (this *Client) SetOnDisconnected(cb func())

func (*Client) SetOnMessage

func (this *Client) SetOnMessage(cb func(topic string, body []byte, qos byte))

func (*Client) Subcribe

func (this *Client) Subcribe(submap map[string]byte) (token session.Token, err error)

订阅主题,可以一次订阅多条 submap

func (*Client) Unsubcribe

func (this *Client) Unsubcribe(subs ...string) (token session.Token, err error)

不订阅主题

Jump to

Keyboard shortcuts

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