-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.go
65 lines (47 loc) · 881 Bytes
/
dev.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
58
59
60
61
62
63
64
65
package main
import (
. "asdf"
"net"
)
const (
cacheCount = 32
devsCount = 256
devIdleTimeout = 10*1000 // ms
)
type dev struct {
mac [MacSize]byte
seq uint64
ack uint64
peer net.Addr
conn *net.PacketConn
ping uint64
pong uint64
idle uint32
cache map[uint64/* seq */]*apiCommandRequest
}
type devChan struct {
}
type devManager struct {
devs map[[MacSize]byte]*dev
ch chan devChan
idle uint
idx uint
}
func (me *devManager) init() {
me.devs = make(map[[MacSize]byte]*dev)
me.ch = make(chan devChan, conf.DevsChanSize)
me.idle = conf.DevIdleTimeout
}
// go it
func (me *devManager) run() {
}
var devManagers []devManager
func devManagerInit() {
devManagers = make([]devManager, conf.DevsCount)
for i:=uint(0); i<conf.DevsCount; i++ {
dm := &devManagers[i]
dm.idx = i
dm.init()
go dm.run()
}
}