TsgcWSPClient_MQTTPropriedades › Client

Client Property

Referencia o TsgcWebSocketClient que transporta os frames MQTT ao conectar sobre WebSockets.

Sintaxe

property Client: TsgcWSComponent_WSClient read FClient write SetClient;

Valor Padrão

nil

Observações

Coloque um TsgcWebSocketClient no formulário e atribua-o a Client para rodar MQTT sobre WebSockets. O cliente WebSocket gerencia o transporte (host, porta, TLS, proxy, cabeçalhos HTTP e negociação de subprotocolo) enquanto este componente implementa a camada de pacotes MQTT por cima. Após a atribuição, o cliente MQTT conecta automaticamente quando o handshake WebSocket é concluído: defina o host/porta no TsgcWebSocketClient e Active := True. Brokers que suportam MQTT sobre WebSocket geralmente escutam na porta 8000 (texto plano) ou 8084 (TLS) e anunciam mqtt como o subprotocolo WebSocket. Utilize Broker quando precisar de TCP bruto.

Exemplo


WSClient := TsgcWebSocketClient.Create(nil);
WSClient.Host := 'broker.hivemq.com';
WSClient.Port := 8000;
MQTT := TsgcWSPClient_MQTT.Create(nil);
MQTT.Client := WSClient;
WSClient.Active := True;

Voltar para Propriedades