-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (39 loc) · 872 Bytes
/
main.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 main
import (
"context"
"time"
"github.com/hkloudou/mqx/face"
"github.com/hkloudou/mqx/plugins/auth/redis"
)
func main() {
obj, err := redis.New(nil)
if err != nil {
panic(err)
}
go obj.MotionExpired(func(userName, clientId string) error {
println("userName", userName)
println("clientId", clientId)
return nil
})
time.Sleep(2 * time.Second)
err = obj.Update(context.TODO(), &face.AuthRequest{
ClientId: "1",
UserName: "mqtt",
PassWord: "public",
}, face.WithAuthRequestTtl(10*time.Second))
if err != nil {
panic(err)
}
// log.Println("wt")
// time.Sleep(1 * time.Second)
// err = obj.Update(context.TODO(), &face.AuthRequest{
// ClientId: "1",
// UserName: "mqtt",
// PassWord: "public",
// }, face.WithAuthRequestTtl(-1))
// if err != nil {
// panic(err)
// }
// time.Sleep(1 * time.Second)
<-make(chan bool)
}