1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-05 16:00:28 +08:00

分离 query & notify

This commit is contained in:
fumiama
2021-12-28 12:47:52 +08:00
parent ff5d9a03c5
commit 45d1ef3abd
3 changed files with 27 additions and 21 deletions

View File

@@ -22,24 +22,3 @@ func (l *Link) keepAlive() {
logrus.Infoln("[link.nat] start to keep alive")
}
}
// 收到询问包的处理函数
func (l *Link) onQuery(packet *head.Packet) {
// TODO: 完成data解包与notify分发
// 1. Data 解包
// ---- 使用 head.Query 解释 packet.Data
// ---- 根据 Query 确定需要封装的 Notify
// 2. notify分发
// ---- 封装 Notify 到 新的 packet.Data
// ---- 调用 l.Send 发送到对方
}
// 收到通告包的处理函数
func (l *Link) onNotify(packet *head.Packet) {
// TODO: 完成data解包与endpoint注册
// 1. Data 解包
// ---- 使用 head.Notify 解释 packet.Data
// 2. endpoint注册
// ---- 遍历 Notify注册对方的 endpoint 到
// ---- connections注意使用读写锁connmapmu
}

13
gold/link/notify.go Normal file
View File

@@ -0,0 +1,13 @@
package link
import "github.com/fumiama/WireGold/gold/head"
// 收到通告包的处理函数
func (l *Link) onNotify(packet *head.Packet) {
// TODO: 完成data解包与endpoint注册
// 1. Data 解包
// ---- 使用 head.Notify 解释 packet.Data
// 2. endpoint注册
// ---- 遍历 Notify注册对方的 endpoint 到
// ---- connections注意使用读写锁connmapmu
}

14
gold/link/query.go Normal file
View File

@@ -0,0 +1,14 @@
package link
import "github.com/fumiama/WireGold/gold/head"
// 收到询问包的处理函数
func (l *Link) onQuery(packet *head.Packet) {
// TODO: 完成data解包与notify分发
// 1. Data 解包
// ---- 使用 head.Query 解释 packet.Data
// ---- 根据 Query 确定需要封装的 Notify
// 2. notify分发
// ---- 封装 Notify 到 新的 packet.Data
// ---- 调用 l.Send 发送到对方
}