Subscribes to a signal and returns the signal handler.

@param  string $signal
@param  mixed  $callback
@return TeamSpeak3_Helper_Signal_Handler
540451
public function subscribe($signal, $callback)
  {
    if(empty($this->sigslots[$signal]))
    {
      $this->sigslots[$signal] = array();
    }

    $index = $this->getCallbackHash($callback);

    if(!array_key_exists($index, $this->sigslots[$signal]))
    {
      $this->sigslots[$signal][$index] = new TeamSpeak3_Helper_Signal_Handler($signal, $callback);
    }

    return $this->sigslots[$signal][$index];
  }
249387
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\LocationService\SwapLocationSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->content1Id);
                eZContentCacheManager::clearContentCacheIfNeeded($signal->content2Id);
                eZSearch::swapNode($signal->location1Id, $signal->location2Id);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
302359
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentService\PublishVersionSignal) {
            return;
        }

        $this->searchHandler->indexContent(
            $this->persistenceHandler->contentHandler()->load($signal->contentId, $signal->versionNo)
        );

        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($signal->contentId);
        foreach ($locations as $location) {
            $this->searchHandler->indexLocation($location);
        }
    }
1050083
public function dispatch($signal, ...$arguments): Promise
    {
        if (\is_object($signal)) {
            \array_unshift($arguments, $signal);

            $signal = \get_class($signal);
        }

        return $this->call($this->handlers->get($signal), $arguments);
    }
1204842
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ObjectStateService\SetContentStateSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId);
                eZSearch::updateObjectState($signal->contentId, [$signal->objectStateId]);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
802397
public function subscribe($channel, callable $handler)
    {
        $loop = $this->client->pubSubLoop();

        $loop->subscribe($channel);

        foreach ($loop as $message) {
            /** @var \stdClass $message */
            if ($message->kind === 'message') {
                call_user_func($handler, Utils::unserializeMessagePayload($message->payload));
            }
        }

        unset($loop);
    }
325514
public function onSignal($signo, callable $callback, $data = null) {
        $watcher = new Watcher;
        $watcher->type = Watcher::SIGNAL;
        $watcher->id = $this->nextId++;
        $watcher->callback = $callback;
        $watcher->value = $signo;
        $watcher->data = $data;

        $this->watchers[$watcher->id] = $watcher;
        $this->enableQueue[$watcher->id] = $watcher;

        return $watcher->id;
    }
89997
def signal_callback(id, signal, data)
      data = Weechat::Utilities.apply_transformation(signal, data, SignalCallbackTransformations)
      Weechat::Hooks::Signal.find_by_id(id).call(signal, data)
    end
373049
public function emit($signal, $args = null)
    {
        if ($this->signalsBlocked) {
            return;
        }

        if (isset($this->signals[$signal]) === false) {
            return;
        }

        /* @var $slots MSlot[] */
        $slots = $this->signals[$signal];

        foreach ($slots as /* @var $slot MSlot */
                 $slot) {
            $method = $slot->getMethod();
            $object = $slot->getReceiver();

            if ($args == null) {
                if ($object == null) {
                    $method();
                } else {
                    $object->$method();
                }
            } else {
                if ($object == null) {
                    $method($args);
                } else {
                    $object->$method($args);
                }
            }
        }
    }
1218660
public function addSignalEvent($signal, $callback, $args=null)
    {
        return $this->add($signal, static::EV_SIGNAL, $callback, $args);
    }
671262
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentService\RevealContentSignal) {
            return;
        }

        $locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent($signal->contentId);
        foreach ($locations as $location) {
            $this->indexSubtree($location->id);
        }
    }
653829
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentService\CopyContentSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->dstContentId);
                eZContentOperationCollection::registerSearchObject($signal->dstContentId);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
951638
public static function callback(
        $msg = '',
        $handler = null,
        $default = null,
        $noValidMessage = null,
        $attemptTimes = 3,
        $failCloseMessage = false
    ) {
        $prompter = new CallbackPrompter();

        $prompter->setHandler($handler);

        static::prepareCallbackPrompter($prompter, $noValidMessage, $attemptTimes, $failCloseMessage);

        return $prompter->ask($msg, $default);
    }
403013
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\LocationService\UpdateLocationSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId);
                eZContentObject::clearCache(); // Clear all object memory cache to free memory
            }
        );
    }
1354196
public static function signal($signals, $callback)
    {
        foreach ($signals as $signal) {
            if (is_null($callback)) {
                \Swoole\Process::signal($signal, null);
                continue;
            }
            \Swoole\Process::signal($signal, function ($signal) use ($callback) {
                try {
                    call_user_func($callback, $signal);
                } catch (\Throwable $e) {
                    \Mix::$app->error->handleException($e);
                }
            });
        }
    }
141800
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\TrashService\TrashSignal) {
            return;
        }

        if ($signal->contentTrashed) {
            $this->searchHandler->deleteContent(
                $signal->contentId
            );
        }

        $this->searchHandler->deleteLocation(
            $signal->locationId,
            $signal->contentId
        );
    }
152729
public function receive(Signal $signal)
    {
        if (!$signal instanceof Signal\ContentTypeService\PublishContentTypeDraftSignal) {
            return;
        }

        $this->runLegacyKernelCallback(
            static function () use ($signal) {
                eZExpiryHandler::registerShutdownFunction();
                $handler = eZExpiryHandler::instance();
                $time = time();
                $handler->setTimestamp('user-class-cache', $time);
                $handler->setTimestamp('class-identifier-cache', $time);
                $handler->setTimestamp('sort-key-cache', $time);
                $handler->store();
            }
        );
    }