TsgcWSPClient_MQTT › Proprietà › Authentication
Invia un nome utente e una password nel pacchetto MQTT CONNECT per autenticare il client presso il broker.
property Authentication: TsgcWSMQTTAuthentication_Options read FAuthentication write SetAuthentication;
Enabled=False
L'autenticazione è disabilitata per impostazione predefinita. Impostare Authentication.Enabled su True e assegnare UserName e Password per includere i campi Username e Password MQTT nel pacchetto CONNECT inviato al broker. Le credenziali sono trasportate a livello MQTT e sono indipendenti dal trasporto WebSocket sottostante: quando Active è impostato su True, il client apre il WebSocket tramite il Client collegato (o TCP grezzo tramite Broker) e poi invia MQTT CONNECT con le credenziali fornite. Per l'autenticazione estesa MQTT 5.0 (challenge/response), utilizzare il campo AuthenticationMethod di ConnectProperties insieme al metodo Auth.
MQTT := TsgcWSPClient_MQTT.Create(nil);
MQTT.Client := WSClient;
MQTT.Authentication.Enabled := True;
MQTT.Authentication.UserName := 'your user';
MQTT.Authentication.Password := 'your password';
WSClient.Active := True;