//go:build windows

package yu_hpsocket

import (
	"fmt"
	"testing"
	"time"
)

func TestHPsocketTcpPackClient(t *testing.T) {
	j_client := NewTcpPackClient()
	fmt.Println(j_client.Create(false))
	j_client.OnPrepareConnect(func(t *TcpPackClient, Sender, ConnID, socket uintptr) HR {
		fmt.Println("j_client.OnPrepareListen", ConnID, socket)
		return HR_OK
	})
	j_client.OnConnect(func(t *TcpPackClient, Sender, ConnID uintptr) HR {
		fmt.Println("j_client.OnConnect", ConnID)
		return HR_OK
	})
	j_client.OnHandShake(func(t *TcpPackClient, Sender, ConnID uintptr) HR {
		fmt.Println("j_client.OnHandShake", Sender, ConnID)
		return HR_OK
	})
	j_client.OnSend(func(t *TcpPackClient, Sender, ConnID, Data uintptr, Length uintptr) HR {
		fmt.Println("j_client.OnSend", Sender, ConnID, Data, Length)
		return HR_OK
	})
	j_client.OnReceive(func(t *TcpPackClient, Sender, ConnID, Data uintptr, Length uintptr) HR {
		fmt.Println("j_client.OnReceive", Sender, ConnID, Data, Length)
		return HR_OK
	})
	j_client.OnClose(func(t *TcpPackClient, Sender, ConnID uintptr, Operation SO, ErrorCode int) HR {
		fmt.Println("j_client.OnClose", Sender, ConnID, Operation, ErrorCode)
		return HR_OK
	})
	// j_client.SetProxy(&yu_proxy.Info{
	// 	Host: "127.0.0.1",
	// 	Port: 808,
	// 	// User:    "111",
	// 	// Pass:    "111",
	// 	Type:    0,
	// 	Timeout: -1,
	// })
	// j_client.SetProxy(&yu_proxy.Info{
	// 	Host: "127.0.0.1",
	// 	Port: 1080,
	// 	// User:    "111",
	// 	// Pass:    "111",
	// 	Type:    1,
	// 	Timeout: -1,
	// })
	fmt.Println(j_client.Start("www.baidu.com", 80, false, "0.0.0.0", 0))
	// fmt.Println(j_client.Start("127.0.0.1", 8011, false, "0.0.0.0", 0))

	j_client.SetNoDelay(true)
	fmt.Println(j_client.GetLastError(), j_client.GetLastErrorDesc())
	fmt.Println(j_client.GetLocalAddress())
	fmt.Println(j_client.GetRemoteHost())
	j_client.SendS("213123123")
	fmt.Println(j_client.GetPendingDataLength())
	j_client.Close()

	time.Sleep(time.Second)

}
