fix
This commit is contained in:
parent
265489956c
commit
7342c0d72a
@ -25,4 +25,9 @@ BLMService:
|
|||||||
#Url: "http://192.168.1.7:8999/LogoCombine"
|
#Url: "http://192.168.1.7:8999/LogoCombine"
|
||||||
Url: "http://18.119.109.254:8999/LogoCombine"
|
Url: "http://18.119.109.254:8999/LogoCombine"
|
||||||
Unity:
|
Unity:
|
||||||
Host: http://api.fusen.3718.cn:4050
|
Host: "http://api.fusen.3718.cn:4050"
|
||||||
|
Udp:
|
||||||
|
LocalAddr: "127.0.0.1"
|
||||||
|
LocalPort: 9100
|
||||||
|
RemoteAddr: "127.0.0.1"
|
||||||
|
RemotePort: 9101
|
@ -27,5 +27,11 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
Unity struct {
|
Unity struct {
|
||||||
Host string
|
Host string
|
||||||
|
Udp struct {
|
||||||
|
LocalAddr string
|
||||||
|
LocalPort int
|
||||||
|
RemoteAddr string
|
||||||
|
RemotePort int
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"fusenapi/server/websocket/internal/config"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
@ -51,8 +52,10 @@ func sendCancelRenderMsgToUnity(wid string, deadlineTime int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 拨号udp
|
// 拨号udp
|
||||||
func DialUdp(ctx context.Context) error {
|
func DialUdp(ctx context.Context, config config.Config) error {
|
||||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{IP: net.ParseIP("localhost"), Port: 9501})
|
localAddr := &net.UDPAddr{IP: net.ParseIP(config.Unity.Udp.LocalAddr), Port: config.Unity.Udp.LocalPort}
|
||||||
|
remoteAddr := &net.UDPAddr{IP: net.ParseIP(config.Unity.Udp.RemoteAddr), Port: config.Unity.Udp.RemotePort}
|
||||||
|
conn, err := net.DialUDP("udp", localAddr, remoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -80,7 +83,7 @@ func ConsumeCancelUnityChanMessage(ctx context.Context, conn *net.UDPConn) {
|
|||||||
d, _ := json.Marshal(data)
|
d, _ := json.Marshal(data)
|
||||||
_, err := conn.Write(d)
|
_, err := conn.Write(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error("发送udp包失败:", err)
|
logx.Error("发送udp包通知Unity失败:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func main() {
|
|||||||
//消费连接统计信息
|
//消费连接统计信息
|
||||||
go logic.ConsumeWebsocketStatData(ctx1)
|
go logic.ConsumeWebsocketStatData(ctx1)
|
||||||
//拨号udp消费控制unity取消僵尸任务的消息
|
//拨号udp消费控制unity取消僵尸任务的消息
|
||||||
if err := logic.DialUdp(ctx1); err != nil {
|
if err := logic.DialUdp(ctx1, c); err != nil {
|
||||||
logx.Error("dail udp err:", err)
|
logx.Error("dail udp err:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user