func (client *Client) Send(pkt Packet) error {

	if client.log != nil && client.LogLevel >= LogLevelDebug {
		client.log.Printf("%.24q < %s", client.id, pkt)
	}

	header := pkt.Header()
	if header.QoS != 0x00 {
		client.pendingMutex.Lock()
		if len(client.pending) >= client.MaxPending {
			client.pendingMutex.Unlock()
			return ErrMaxPending
		}

		var id int
		switch packet := pkt.(type) {
		case *PublishPacket:
			id = packet.ID
		case *PubRelPacket:
			id = packet.ID
		case *SubscribePacket:
			id = packet.ID
		case *UnsubscribePacket:
			id = packet.ID
		}

		client.pending[id] = pkt
		client.pendingMutex.Unlock()
	}

	return client.stream.WritePacket(pkt)
}
// Send a MQTT controll packet.
Send a MQTT controll packet.
// Send a MQTT controll packet .
func (client *Client) Send(pkt Packet) error {
	if client.log != nil && client.LogLevel >= LogLevelDebug {
		client.log.Printf("%.24q < %s", client.id, pkt)
	}
	header := pkt.Header()
	if header.QoS != 0x00 {
		client.pendingMutex.Lock()
		if len(client.pending) >= client.MaxPending {
			client.pendingMutex.Unlock()
			return ErrMaxPending
		}
		var id int
		switch packet := pkt.(type) {
		case *PublishPacket:
			id = packet.ID
		case *PubRelPacket:
			id = packet.ID
		case *SubscribePacket:
			id = packet.ID
		case *UnsubscribePacket:
			id = packet.ID
		}
		client.pending[id] = pkt
		client.pendingMutex.Unlock()
	}
	return client.stream.WritePacket(pkt)
}
func ( client * Client ) Send ( pkt Packet ) error { if client . log != nil && client . LogLevel >= LogLevelDebug { client . log . Printf ( " " , client . id , pkt ) } header := pkt . Header ( ) if header . QoS != 0x00 { client . pendingMutex . Lock ( ) if len ( client . pending ) >= client . MaxPending { client . pendingMutex . Unlock ( ) return ErrMaxPending } var id int switch packet := pkt . ( type ) { case * PublishPacket : id = packet . ID case * PubRelPacket : id = packet . ID case * SubscribePacket : id = packet . ID case * UnsubscribePacket : id = packet . ID } client . pending [ id ] = pkt client . pendingMutex . Unlock ( ) } return client . stream . WritePacket ( pkt ) }
Send a MQTT controll packet.
Send a MQTT controll packet .