TsgcWSPClient_MQTT메서드 › Disconnect

Disconnect 메서드

세션을 깔끔하게 종료하기 위해 MQTT DISCONNECT 패킷을 보냅니다.

Overloads

오버로드 1

구문

procedure Disconnect;

설명

이유 코드 0(Normal Disconnection)과 추가 속성 없이 표준 MQTT 연결 해제를 수행합니다. 애플리케이션이 단순히 로그오프하고 Last Will 메시지의 전달을 억제하려는 경우 이 오버로드를 사용하십시오. 기본 WebSocket 전송은 여기에서 닫히지 않습니다. 소켓을 해제하려면 부모 클라이언트의 Disconnect를 호출하십시오.

예제

MQTT.Disconnect;

Overload 2

구문

procedure Disconnect(aReasonCode: Integer; aDisconnectProperties: TsgcWSMQTTDisconnect_Properties = nil);

Parameters

NameType설명
aReasonCodeInteger브로커에 보고되는 MQTT 5.0 reason code입니다(예: 0 = Normal, 4 = Disconnect with Will Message, 129 = Malformed Packet, 139 = Server Shutting Down).
aDisconnectPropertiesTsgcWSMQTTDisconnect_PropertiesSession Expiry Interval, Reason String, Server Reference 또는 User Properties와 같은 선택적 MQTT 5.0 속성입니다. 속성이 필요하지 않은 경우 nil을 전달하십시오.

설명

클라이언트가 떠나는 이유를 알릴 수 있게 해주는 MQTT 5.0 오버로드입니다. aReasonCode를 4로 설정하면 브로커에게 구성된 Last Will Testament를 게시하도록 요청하는 반면, 0이 아닌 코드는 브로커가 비정상 종료를 로깅하게 합니다. 세션이 MQTT 3.1.1로 협상된 경우 무시됩니다.

예제

oProps := TsgcWSMQTTDisconnect_Properties.Create;
try
  oProps.ReasonString := 'client shutting down';
  MQTT.Disconnect(0, oProps);
finally
  oProps.Free;
end;

메서드로 돌아가기