12345678910111213141516171819202122232425262728293031 |
- package main
- import (
- "fmt"
- "sparrow/pkg/protocol"
- )
- type Agent struct {
- }
- // Message 收到设备上报消息处理
- func (a *Agent) Message(topic string, payload []byte) error {
- fmt.Printf("%s, %s\r\n", topic, payload)
- return nil
- }
- // Connected 设备接入时
- func (a *Agent) Connected(status *protocol.DevConnectStatus) error {
- fmt.Printf("%v\r\n", status)
- return nil
- }
- // Disconnected 设备断开连接时
- func (a *Agent) Disconnected(status *protocol.DevConnectStatus) error {
- fmt.Printf("%v\r\n", status)
- return nil
- }
- func NewAgent() *Agent {
- return &Agent{}
- }
|