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://18.119.109.254:8999/LogoCombine"
|
||||
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 {
|
||||
Host string
|
||||
Udp struct {
|
||||
LocalAddr string
|
||||
LocalPort int
|
||||
RemoteAddr string
|
||||
RemotePort int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func main() {
|
|||
//消费连接统计信息
|
||||
go logic.ConsumeWebsocketStatData(ctx1)
|
||||
//拨号udp消费控制unity取消僵尸任务的消息
|
||||
if err := logic.DialUdp(ctx1); err != nil {
|
||||
if err := logic.DialUdp(ctx1, c); err != nil {
|
||||
logx.Error("dail udp err:", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user