public function onClose(ConnectionInterface $conn) {
    $this->logger->notice("Client skedaddled. ({$conn->resourceId})");

    $mess = 0;
    foreach ($this->querySubs as $curEtype => &$curSubscriptions) {
      foreach ($curSubscriptions as $curQuery => &$curClients) {
        if ($curClients->contains($conn)) {
          unset($curClients[$conn]);

          $count = count($curClients);

          if ($count === 0) {
            unset($curSubscriptions[$curQuery]);
            if (count($this->querySubs[$curEtype]) === 0) {
              unset($this->querySubs[$curEtype]);
            }
          } else {
            if (Server::$config['broadcast_counts']) {
              // Notify clients of the subscription count.
              foreach ($curClients as $key) {
                $curData = $curClients[$key];
                if ($curData['count']) {
                  $key->send(json_encode([
                    'query' => $curData['query'],
                    'count' => $count
                  ]));
                }
              }
            }
          }
          $mess++;
        }
      }
      unset($curClients);
    }
    unset($curSubscriptions);

    foreach ($this->uidSubs as $curUID => $curClients) {
      if ($curClients->contains($conn)) {
        unset($curClients[$conn]);

        $count = count($curClients);

        if ($count === 0) {
          unset($this->uidSubs[$curUID]);
        } else {
          if (Server::$config['broadcast_counts']) {
            // Notify clients of the subscription count.
            foreach ($curClients as $key) {
              $curData = $curClients[$key];
              if ($curData['count']) {
                $key->send(json_encode([
                  'uid' => $curUID,
                  'count' => $count
                ]));
              }
            }
          }
        }
        $mess++;
      }
    }

    if ($this->sessions->contains($conn)) {
      unset($this->sessions[$conn]);
      $mess++;
    }

    if ($mess) {
      $this->logger->notice(
          "Cleaned up client's mess. ".
            "($mess, {$conn->resourceId})"
      );
    }
  }
public function onClose(ConnectionInterface $conn) {
    $this->logger->notice("Client skedaddled. ({$conn->resourceId})");

    $mess = 0;
    foreach ($this->querySubs as $curEtype => &$curSubscriptions) {
      foreach ($curSubscriptions as $curQuery => &$curClients) {
        if ($curClients->contains($conn)) {
          unset($curClients[$conn]);

          $count = count($curClients);

          if ($count === 0) {
            unset($curSubscriptions[$curQuery]);
            if (count($this->querySubs[$curEtype]) === 0) {
              unset($this->querySubs[$curEtype]);
            }
          } else {
            if (Server::$config['broadcast_counts']) {
              // Notify clients of the subscription count.
              foreach ($curClients as $key) {
                $curData = $curClients[$key];
                if ($curData['count']) {
                  $key->send(json_encode([
                    'query' => $curData['query'],
                    'count' => $count
                  ]));
                }
              }
            }
          }
          $mess++;
        }
      }
      unset($curClients);
    }
    unset($curSubscriptions);

    foreach ($this->uidSubs as $curUID => $curClients) {
      if ($curClients->contains($conn)) {
        unset($curClients[$conn]);

        $count = count($curClients);

        if ($count === 0) {
          unset($this->uidSubs[$curUID]);
        } else {
          if (Server::$config['broadcast_counts']) {
            // Notify clients of the subscription count.
            foreach ($curClients as $key) {
              $curData = $curClients[$key];
              if ($curData['count']) {
                $key->send(json_encode([
                  'uid' => $curUID,
                  'count' => $count
                ]));
              }
            }
          }
        }
        $mess++;
      }
    }

    if ($this->sessions->contains($conn)) {
      unset($this->sessions[$conn]);
      $mess++;
    }

    if ($mess) {
      $this->logger->notice(
          "Cleaned up client's mess. ".
            "($mess, {$conn->resourceId})"
      );
    }
  }
public function onClose ( ConnectionInterface $ conn ) { $ this -> logger -> notice ( "Client skedaddled. ({$conn->resourceId})" ) ; $ mess = 0 ; foreach ( $ this -> querySubs as $ curEtype => & $ curSubscriptions ) { foreach ( $ curSubscriptions as $ curQuery => & $ curClients ) { if ( $ curClients -> contains ( $ conn ) ) { unset ( $ curClients [ $ conn ] ) ; $ count = count ( $ curClients ) ; if ( $ count === 0 ) { unset ( $ curSubscriptions [ $ curQuery ] ) ; if ( count ( $ this -> querySubs [ $ curEtype ] ) === 0 ) { unset ( $ this -> querySubs [ $ curEtype ] ) ; } } else { if ( Server :: $ config [ 'broadcast_counts' ] ) { // Notify clients of the subscription count. foreach ( $ curClients as $ key ) { $ curData = $ curClients [ $ key ] ; if ( $ curData [ 'count' ] ) { $ key -> send ( json_encode ( [ 'query' => $ curData [ 'query' ] , 'count' => $ count ] ) ) ; } } } } $ mess ++ ; } } unset ( $ curClients ) ; } unset ( $ curSubscriptions ) ; foreach ( $ this -> uidSubs as $ curUID => $ curClients ) { if ( $ curClients -> contains ( $ conn ) ) { unset ( $ curClients [ $ conn ] ) ; $ count = count ( $ curClients ) ; if ( $ count === 0 ) { unset ( $ this -> uidSubs [ $ curUID ] ) ; } else { if ( Server :: $ config [ 'broadcast_counts' ] ) { // Notify clients of the subscription count. foreach ( $ curClients as $ key ) { $ curData = $ curClients [ $ key ] ; if ( $ curData [ 'count' ] ) { $ key -> send ( json_encode ( [ 'uid' => $ curUID , 'count' => $ count ] ) ) ; } } } } $ mess ++ ; } } if ( $ this -> sessions -> contains ( $ conn ) ) { unset ( $ this -> sessions [ $ conn ] ) ; $ mess ++ ; } if ( $ mess ) { $ this -> logger -> notice ( "Cleaned up client's mess. " . "($mess, {$conn->resourceId})" ) ; } }
Clean up after users who leave.

@param ConnectionInterface $conn
Clean up after users who leave .