websocket

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(client Client) (err error)

Check 检查插件包基础功能

Types

type Attribute

type Attribute struct {
	InstanceID int         `json:"instance_id"`
	Attribute  string      `json:"attribute"`
	Val        interface{} `json:"val"`
}

type Client

type Client struct {
	Conn
	Token     string // SA登录token
	PluginID  string // 插件id
	Formatted bool   // 是否格式化输出
}

func GetClient

func GetClient(c Client) (Client, error)

GetClient 获取客户端

func (*Client) Discover

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

Discover 发现特定品牌设备

func (*Client) GetAttributes

func (c *Client) GetAttributes(identify string) (err error)

GetAttributes 获取设备属性

func (*Client) SetAttributes

func (c *Client) SetAttributes(identify string, attr ...Attribute) (err error)

SetAttributes 修改设备属性

type Conn

type Conn struct {
	*websocket.Conn
}

func GetConn

func GetConn(host string, rawQuery string) (c Conn, err error)

GetConn 获取连接

func (*Conn) Read

func (c *Conn) Read() (msg []byte, err error)

Read 读取消息

func (*Conn) Write

func (c *Conn) Write(msg string) error

Write 发送消息

type MsgDiscover

type MsgDiscover struct {
	Domain  string `json:"domain"`
	ID      int    `json:"id"`
	Service string `json:"service"`
}

type MsgGetAttribute

type MsgGetAttribute struct {
	ID       int    `json:"id"`
	Domain   string `json:"domain"`
	Service  string `json:"service"`
	Identity string `json:"identity"`
}

type MsgSetAttribute

type MsgSetAttribute struct {
	MsgGetAttribute
	ServiceData `json:"service_data"`
}

type ServiceData

type ServiceData struct {
	Attributes []Attribute `json:"attributes"`
}

Jump to

Keyboard shortcuts

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