-
Notifications
You must be signed in to change notification settings - Fork 41
/
client.go
57 lines (45 loc) · 954 Bytes
/
client.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
45
46
47
48
49
50
51
52
53
54
55
56
57
package canopus
import "net"
func Dial(address string) (conn Connection, err error) {
udpConn, err := net.Dial("udp", address)
if err != nil {
return
}
conn = &UDPConnection{
conn: udpConn,
}
return
}
func DialDTLS(address, identity, psk string) (conn Connection, err error) {
udpConn, err := net.Dial("udp", address)
if err != nil {
return
}
conn, err = NewDTLSConnection(udpConn, identity, psk)
if err != nil {
return
}
return
}
func NewObserveMessage(r string, val interface{}, msg Message) ObserveMessage {
return &CoapObserveMessage{
Resource: r,
Value: val,
Msg: msg,
}
}
type CoapObserveMessage struct {
CoapMessage
Resource string
Value interface{}
Msg Message
}
func (m *CoapObserveMessage) GetResource() string {
return m.Resource
}
func (m *CoapObserveMessage) GetValue() interface{} {
return m.Value
}
func (m *CoapObserveMessage) GetMessage() Message {
return m.GetMessage()
}