mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
reorder payload type check in udp client
This commit is contained in:
@@ -76,6 +76,11 @@ func (uc *UDPClient) Run() error {
|
|||||||
|
|
||||||
func (uc *UDPClient) Output(payload any) error {
|
func (uc *UDPClient) Output(payload any) error {
|
||||||
|
|
||||||
|
payloadBytes, ok := payload.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("net.udp.client is only able to output bytes")
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -83,11 +88,6 @@ func (uc *UDPClient) Output(payload any) error {
|
|||||||
|
|
||||||
uc.conn = client
|
uc.conn = client
|
||||||
|
|
||||||
payloadBytes, ok := payload.([]byte)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("net.udp.client is only able to output bytes")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = uc.conn.Write(payloadBytes)
|
_, err = uc.conn.Write(payloadBytes)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user