-
Notifications
You must be signed in to change notification settings - Fork 0
/
postoffice.go
44 lines (38 loc) · 965 Bytes
/
postoffice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package postoffice
import (
"github.com/IvoryRaptor/dragonfly"
"github.com/IvoryRaptor/dragonfly/mq"
"github.com/IvoryRaptor/postoffice-plus"
"github.com/IvoryRaptor/postoffice-plus/mqtt/message"
)
type ChannelConfig struct {
DeviceName string
Matrix string
}
type AuthBlock struct {
ClientId string
DeviceName string
ProductKey string
SecureMode int
SignMethod string
Keys []string
Params map[string]string
Username string
Password string
}
type IAuthenticator interface {
dragonfly.IService
Authenticate(block *AuthBlock) *ChannelConfig
}
type IClient interface {
Send(msg *postoffice_plus.MQMessage) error
Stop()
}
type IPostOffice interface {
mq.IArrive
GetTopics(matrix string, action string) []string
Authenticate(msg *message.ConnectMessage) *ChannelConfig
Publish(channel *ChannelConfig, resource string, action string, payload []byte) error
AddDevice(device string, client IClient)
Close(device string)
}