func (c *Client) Read(h func(*Client, packets.Packet) error) error {
	for {
		if atomic.LoadInt32(&c.State.Done) == 1 && c.r.CapDelta() == 0 {
			return nil
		}

		c.refreshDeadline(c.keepalive)
		fh := new(packets.FixedHeader)
		err := c.ReadFixedHeader(fh)
		if err != nil {
			return err
		}

		pk, err := c.ReadPacket(fh)
		if err != nil {
			return err
		}

		err = h(c, pk) // Process inbound packet.
		if err != nil {
			return err
		}
	}
}
// Read reads new packets from a client connection
Read reads new packets from a client connection
// Read reads new packets from a client connection
func (c *Client) Read(h func(*Client, packets.Packet) error) error {
	for {
		if atomic.LoadInt32(&c.State.Done) == 1 && c.r.CapDelta() == 0 {
			return nil
		}
		c.refreshDeadline(c.keepalive)
		fh := new(packets.FixedHeader)
		err := c.ReadFixedHeader(fh)
		if err != nil {
			return err
		}
		pk, err := c.ReadPacket(fh)
		if err != nil {
			return err
		}
		err = h(c, pk) 
		if err != nil {
			return err
		}
	}
}
func ( c * Client ) Read ( h func ( * Client , packets . Packet ) error ) error { for { if atomic . LoadInt32 ( & c . State . Done ) == 1 && c . r . CapDelta ( ) == 0 { return nil } c . refreshDeadline ( c . keepalive ) fh := new ( packets . FixedHeader ) err := c . ReadFixedHeader ( fh ) if err != nil { return err } pk , err := c . ReadPacket ( fh ) if err != nil { return err } err = h ( c , pk ) if err != nil { return err } } }
Read reads new packets from a client connection
Read reads new packets from a client connection
// Process inbound packet.