PHP 8.4.0 RC2 available for testing

Stomp::__destruct

stomp_close

(PECL stomp >= 0.1.0)

Stomp::__destruct -- stomp_closeFerme une connexion

Description

Style orienté objet (destructeur) :

public Stomp::__destruct()

Style procédural :

stomp_close(resource $link): bool

Ferme une connexion préalablement ouverte.

Liste de paramètres

link

Style procédural uniquement : L'identifiant stomp retourné par la fonctionstomp_connect().

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Exemples

Voir stomp_connect().

add a note

User Contributed Notes 1 note

up
0
vanja at removethis dizyart period com
5 years ago
Isn't it a little odd to have connect/disconnect in the constructor/destructor methods?
I have a case where the connection is presumably kept alive until the PHP process ends:

<?php
class MyStompWrapper {
public function
doSend()
{
$stomp = $this->connect(); // returns Stomp Object
$stomp->send('/destination', 'message', []);
$this->disconnect($stomp);
// $stomp still exists in this scope, hence, the connection is alive
}

private function
disconnect(\Stomp $stompObj)
{
// only unsets the local $stomp pointer, does not actually disconnect
unset($stomp);
}

private function
connect():\Stomp
{
// try-catch block omitted for example brevity
return new Stomp('url', 'username', 'password');
}
}
?>

This means that, in order to handle disconnecting, I have to create and destroy the Stomp object within the same scope.
To Top