//go:build windows package yu_hpsocket import ( "fmt" yu_fast "gogs.qqck.cn/s/tools/fast" "testing" "time" ) func TestHPsocketTcpPackServer(t *testing.T) { j_server := NewTcpPackServer() fmt.Println(j_server.Create(false)) j_server.OnPrepareListen(func(t *TcpPackServer, Sender, Listen uintptr) HR { fmt.Println("j_server.OnPrepareListen", Sender, Listen) return HR_OK }) j_server.OnAccept(func(t *TcpPackServer, Sender, ConnID, Client uintptr) HR { fmt.Println("j_server.OnConnect", ConnID) fmt.Println(t.GetRemoteAddress(ConnID)) return HR_OK }) j_server.OnHandShake(func(t *TcpPackServer, Sender, ConnID uintptr) HR { fmt.Println("j_server.OnHandShake", Sender, ConnID) return HR_OK }) j_server.OnSend(func(t *TcpPackServer, Sender, ConnID, Data uintptr, Length uintptr) HR { fmt.Println("j_server.OnSend", Sender, ConnID, Data, Length) return HR_OK }) j_server.OnReceive(func(t *TcpPackServer, Sender, ConnID, Data uintptr, Length uintptr) HR { fmt.Println("j_server.OnReceive", Sender, ConnID, Data, Length) fmt.Println("j_server.OnSend", t.Send(ConnID, yu_fast.P2B(Data, Length))) return HR_OK }) j_server.OnClose(func(t *TcpPackServer, Sender, ConnID uintptr, Operation SO, ErrorCode int) HR { fmt.Println("j_server.OnClose", Sender, ConnID, Operation, ErrorCode) return HR_OK }) j_server.OnShutdown(func(t *TcpPackServer, Sender uintptr) HR { fmt.Println("j_server.OnShutdown", Sender) return HR_OK }) fmt.Println(j_server.Start("0.0.0.0", 8011)) fmt.Println(j_server.GetLastError(), j_server.GetLastErrorDesc()) time.Sleep(time.Second * 1000 * 1000) }