59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"joylink.club/bj-rtsts-server/third_party/balise"
|
|
)
|
|
|
|
type TestMsg struct {
|
|
Msg string
|
|
Port int
|
|
}
|
|
|
|
func (t *TestMsg) Encode() []byte {
|
|
b := []byte(t.Msg)
|
|
// binary.BigEndian.PutUint16(b, uint16(t.Port))
|
|
return b
|
|
}
|
|
|
|
func (t *TestMsg) Decode(data []byte) error {
|
|
t.Msg = string(data)
|
|
// t.Port = int(binary.BigEndian.Uint16(data))
|
|
return nil
|
|
}
|
|
|
|
func handleUdpMsg(b []byte) {
|
|
slog.Info("udp server handle", "msg", string(b))
|
|
}
|
|
|
|
func main() {
|
|
// udp.NewServer("127.0.0.1:6666", handleUdpMsg).Listen()
|
|
|
|
// client := udp.NewClient("127.0.0.1:7777")
|
|
// for i := 0; i < 1000; i++ {
|
|
// time.Sleep(time.Millisecond * 500)
|
|
// client.Send(&TestMsg{
|
|
// Msg: "test, port = 7777",
|
|
// })
|
|
// }
|
|
|
|
// time.Sleep(time.Second * 60)
|
|
// for i, v := range balise.ConvWords {
|
|
// fmt.Printf("0%o,", v)
|
|
// if i%10 == 9 {
|
|
// fmt.Println()
|
|
// }
|
|
// }
|
|
v10 := balise.ToVal([]int{
|
|
1, 1, 1,
|
|
1, 1, 1, 1,
|
|
1, 1, 1, 1,
|
|
1, 1, 1, 1})
|
|
fmt.Println(v10)
|
|
bs := balise.ToBits(1982, 11)
|
|
fmt.Println(bs)
|
|
// fmt.Printf("%o\n", balise.ConvWords[511])
|
|
}
|