private function handleSubscriptionUid(ConnectionInterface $from, $data) {
    if ($data['action'] === 'subscribe') {
      // Client is subscribing to a UID.
      if (!key_exists($data['uid'], $this->uidSubs)) {
        $this->uidSubs[$data['uid']] = new \SplObjectStorage();
      }
      $this->uidSubs[$data['uid']][$from] = [
        'count' => !!$data['count']
      ];
      $this->logger->notice(
          "Client subscribed to a UID! ".
            "({$data['uid']}, {$from->resourceId})"
      );

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

    if ($data['action'] === 'unsubscribe') {
      // Client is unsubscribing from a UID.
      if (!key_exists($data['uid'], $this->uidSubs)) {
        return;
      }
      if (!$this->uidSubs[$data['uid']]->contains($from)) {
        return;
      }
      unset($this->uidSubs[$data['uid']][$from]);
      $this->logger->notice(
          "Client unsubscribed from a UID! ".
            "({$data['uid']}, {$from->resourceId})"
      );

      $count = count($this->uidSubs[$data['uid']]);

      if ($count === 0) {
        // No more subscribed clients.
        unset($this->uidSubs[$data['uid']]);
        return;
      }

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