mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
switch net.udp.client conn to pointer
This commit is contained in:
@@ -10,7 +10,7 @@ type UDPClient struct {
|
|||||||
config ModuleConfig
|
config ModuleConfig
|
||||||
Host string
|
Host string
|
||||||
Port uint16
|
Port uint16
|
||||||
conn net.Conn
|
conn *net.UDPConn
|
||||||
router *Router
|
router *Router
|
||||||
addr *net.UDPAddr
|
addr *net.UDPAddr
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,9 @@ func (uc *UDPClient) Run() error {
|
|||||||
|
|
||||||
<-uc.router.Context.Done()
|
<-uc.router.Context.Done()
|
||||||
slog.Debug("router context done in module", "id", uc.config.Id)
|
slog.Debug("router context done in module", "id", uc.config.Id)
|
||||||
|
if uc.conn != nil {
|
||||||
|
uc.conn.Close()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +84,7 @@ func (uc *UDPClient) Output(payload any) error {
|
|||||||
return fmt.Errorf("net.udp.client is only able to output bytes")
|
return fmt.Errorf("net.udp.client is only able to output bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(jwetzell): reuse connection or setup new one when necessary
|
||||||
client, err := net.DialUDP("udp", nil, uc.addr)
|
client, err := net.DialUDP("udp", nil, uc.addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user