fix
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"fusenapi/server/websocket/internal/config"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"net"
|
||||
"time"
|
||||
@@ -51,8 +52,10 @@ func sendCancelRenderMsgToUnity(wid string, deadlineTime int64) {
|
||||
}
|
||||
|
||||
// 拨号udp
|
||||
func DialUdp(ctx context.Context) error {
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{IP: net.ParseIP("localhost"), Port: 9501})
|
||||
func DialUdp(ctx context.Context, config config.Config) error {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@@ -80,7 +83,7 @@ func ConsumeCancelUnityChanMessage(ctx context.Context, conn *net.UDPConn) {
|
||||
d, _ := json.Marshal(data)
|
||||
_, err := conn.Write(d)
|
||||
if err != nil {
|
||||
logx.Error("发送udp包失败:", err)
|
||||
logx.Error("发送udp包通知Unity失败:", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user