修改udp服务未启动监听问题
This commit is contained in:
parent
fa0167271f
commit
7542ee473c
1
third_party/dynamics/dynamics.go
vendored
1
third_party/dynamics/dynamics.go
vendored
@ -78,6 +78,7 @@ func newDynamics() Dynamics {
|
||||
},
|
||||
}
|
||||
d.trainInfoUdpServer = udp.NewServer(fmt.Sprintf(":%d", config.Config.Dynamics.UdpLocalPort), d.handleDynamicsTrainInfo)
|
||||
d.trainInfoUdpServer.Listen()
|
||||
return d
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ func newSemiPhysicalTrain() SemiPhysicalTrain {
|
||||
trainSpeedInfoUdpClient: udp.NewClient("127.0.0.1:7777"),
|
||||
}
|
||||
s.trainControlUdpServer = udp.NewServer(fmt.Sprintf(":%d", config.Config.Dynamics.UdpLocalPort), s.handleTrainControlMsg)
|
||||
s.trainControlUdpServer.Listen()
|
||||
return s
|
||||
}
|
||||
|
||||
|
4
third_party/udp/udp_server.go
vendored
4
third_party/udp/udp_server.go
vendored
@ -3,6 +3,7 @@ package udp
|
||||
import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
type UdpServer interface {
|
||||
@ -54,7 +55,8 @@ func (s *server) listenAndHandle() {
|
||||
func (s *server) handle(b []byte) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
slog.Error("udp server handle error", err)
|
||||
slog.Error("udp server handle error", "error", err, "stack", string(debug.Stack()))
|
||||
debug.PrintStack()
|
||||
}
|
||||
}()
|
||||
// slog.Info("udp server handle", "msg", string(b))
|
||||
|
Loading…
Reference in New Issue
Block a user