Connection | Client AMQP1 Disconnect

The client can disconnect a current active connection, using the following methods:

 

Sending a Close Reason

The AMQP client can inform the server that the connection will be closed and provide information about the reason why is closing the connection. Use the method Close to request a connection close to the server.

 


oAMQP.Close('invalid-frame', 'The received frame has an invalid format.');

 

 

Await Close

 

By default, the Close method is Asynchronous, so after calling the method, the code continue. If you want to wait till the Close method is completed and the confirmation sent by the server is received, set the property Await to True in the Options parameter.

 


procedure Close(const aCondition, aDescription: string);
var
  oOptions: TsgcAMQP1MethodOptions_Close;
begin
  oOptions := TsgcAMQP1MethodOptions_Close.Create;
  Try
    oOptions.ErrorCondition := aCondition;
	oOptions.ErrorDescription := aDescription;
    oOptions.Await := True;
    AMQP1.Close(oOptions);
  Finally
    oOptions.Free;
  End;
end;

 

Closing Socket Connection

Just set the property Active of TsgcWebSocketClient to False. You can read more about closing connections.