mirror of
https://github.com/fumiama/WireGold.git
synced 2025-09-26 19:21:11 +08:00
22 lines
476 B
Go
22 lines
476 B
Go
package link
|
|
|
|
import (
|
|
"github.com/RomiChan/syncx"
|
|
"github.com/fumiama/WireGold/gold/head"
|
|
)
|
|
|
|
// 事件分发器
|
|
var dispachers syncx.Map[uint8, Dispacher]
|
|
|
|
type Dispacher func(header *head.Packet, peer *Link, data []byte)
|
|
|
|
// RegisterDispacher of proto
|
|
func RegisterDispacher(p uint8, d Dispacher) (actual Dispacher, hasexist bool) {
|
|
return dispachers.LoadOrStore(p, d)
|
|
}
|
|
|
|
// GetDispacher fn, ok
|
|
func GetDispacher(p uint8) (Dispacher, bool) {
|
|
return dispachers.Load(p)
|
|
}
|