|
@@ -7,20 +7,21 @@ import (
|
|
|
mu "mfw/util"
|
|
|
"net"
|
|
|
qu "qfw/util"
|
|
|
+ "sync"
|
|
|
)
|
|
|
|
|
|
var (
|
|
|
udpclient mu.UdpClient
|
|
|
+ udpLock sync.Mutex
|
|
|
)
|
|
|
|
|
|
func InitUdpMsg() {
|
|
|
- port := ":5550"
|
|
|
- udpclient = mu.UdpClient{Local: ":5550", BufSize: 1024}
|
|
|
+ port := ":1581"
|
|
|
+ udpclient = mu.UdpClient{Local: port, BufSize: 1024}
|
|
|
udpclient.Listen(processUdpMsg)
|
|
|
log.Debug("监听~", port)
|
|
|
}
|
|
|
|
|
|
-//udp接收
|
|
|
func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
|
|
|
switch act {
|
|
|
case mu.OP_TYPE_DATA:
|
|
@@ -35,13 +36,30 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
|
|
|
} else {
|
|
|
key := sid + "-" + eid + "-" + qu.ObjToString(mapInfo["stype"])
|
|
|
udpclient.WriteUdp([]byte(key), mu.OP_NOOP, ra)
|
|
|
+ udpLock.Lock()
|
|
|
bidding.RunPurchasingInfo(sid, eid, true)
|
|
|
+ udpLock.Unlock()
|
|
|
+ //处理完毕~发送
|
|
|
+ processNextNode(sid, eid, key)
|
|
|
}
|
|
|
}
|
|
|
case mu.OP_NOOP: //下个节点回应
|
|
|
ok := string(data)
|
|
|
if ok != "" {
|
|
|
- log.Debug("ok:", ok)
|
|
|
+ log.Debug("接收~", ok)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func processNextNode(sid string, eid string, key string) {
|
|
|
+ by, _ := json.Marshal(map[string]interface{}{
|
|
|
+ "gtid": sid,
|
|
|
+ "lteid": eid,
|
|
|
+ "key": key,
|
|
|
+ })
|
|
|
+ addr := &net.UDPAddr{
|
|
|
+ IP: net.ParseIP("172.17.4.189"),
|
|
|
+ Port: 1582,
|
|
|
+ }
|
|
|
+ udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
|
|
|
+}
|