我正在尝试创建一个映射,以将密钥保存为连接的客户端及其有效负载信息。这是我的代码。我该怎么做呢
代码允许客户端将有效负载信息发送到服务器
package main
import (
"fmt"
"log"
"net"
"github.com/dustin/go-coap"
)
func main() {
//listening for inconming request
log.Fatal(coap.ListenAndServe("udp", ":5683",
//function to handle incoming Client COAP Request u...dpconnection from Remote Host & the udp address of remote
coap.FuncHandler(func(l *net.UDPConn, a *net.UDPAddr, m *coap.Message) *coap.Message {
log.Printf("Got message path=%q: %#v from %v", m.Path(), m, a)
var connection = make(map[net.UDPConn]coap.Message)
fmt.Println(connection)
// connection[l]= m.Payload[]
fmt.Println("The connecion is ", connection)
//var connection =make(map[]m) //check if the message of client is confirmed with the
if m.IsConfirmable() {
res := &coap.Message{
Type: coap.Acknowledgement,
Code: coap.Content,
MessageID: m.MessageID,
Token: m.Token,
Payload: []byte("Acknowledgement from Sever : hello to you!")}
res.SetOption(coap.ContentFormat, coap.TextPlain)
log.Printf("Got it client %s %T", m.Payload, &res)
return res
}
return nil
})))
}