rts-sim-testing-service/third_party/radar/radar_test.go

30 lines
736 B
Go
Raw Normal View History

2024-01-24 17:12:34 +08:00
package radar
import (
"encoding/json"
"fmt"
"joylink.club/bj-rtsts-server/third_party/message"
"joylink.club/bj-rtsts-server/third_party/udp"
"testing"
)
func TestUdp(t *testing.T) {
2024-04-11 08:55:12 +08:00
fmt.Println(0 | (byte(1) << 7) | (byte(1) << 6) | (byte(1) << 5) | (byte(1) << 4) | (byte(1) << 1) | (byte(1) << 0))
fmt.Println(fmt.Sprintf("%b", 0|(byte(1)<<7)|(byte(1)<<6)|(byte(1)<<5)|(byte(1)<<4)|(byte(1)<<1)|(byte(1)<<0)))
2024-01-24 17:12:34 +08:00
fmt.Println("准备启动服务...")
addr := fmt.Sprintf("%v:%v", "127.0.0.1", "8899")
server := udp.NewServer(addr, handle)
server.Listen()
2024-01-29 18:05:14 +08:00
select {}
2024-01-24 17:12:34 +08:00
}
func handle(d []byte) {
ri := message.RadarInfo{}
err := ri.Decode(d)
if err == nil {
jsonD, _ := json.Marshal(ri)
fmt.Println(string(jsonD))
}
}