KeepAlive enhancement.

If the server doesn't send keepalive for 20 seconds, generate an error.
fix #251, close #255
This commit is contained in:
Tnze
2023-06-25 22:08:13 +08:00
parent d0ef493639
commit 940df0a968
3 changed files with 17 additions and 3 deletions

View File

@ -44,14 +44,14 @@ func NewClient() *Client {
// Conn is a concurrently-safe warpper of net.Conn with packet queue.
// Note that not all methods are concurrently-safe.
type Conn struct {
conn *net.Conn
*net.Conn
send, recv queue.Queue[pk.Packet]
rerr error
}
func warpConn(c *net.Conn) *Conn {
wc := Conn{
conn: c,
Conn: c,
send: make(queue.ChannelQueue[pk.Packet], 256),
recv: make(queue.ChannelQueue[pk.Packet], 256),
rerr: nil,
@ -104,7 +104,7 @@ func (c *Conn) WritePacket(p pk.Packet) error {
func (c *Conn) Close() error {
c.send.Close()
return c.conn.Close()
return c.Conn.Close()
}
// Position is a 3D vector.