예제 #1
0
 public function handleEvent(Event $event) : Promise
 {
     if (!isset($this->eventHandlers[$event->getTypeId()])) {
         return new Success();
     }
     return all(array_map(function (BuiltInEventHandler $handler) use($event) {
         return $handler->handleEvent($event);
     }, $this->eventHandlers[$event->getTypeId()]));
 }
예제 #2
0
 /**
  * @param Event $event
  * @return Promise[]
  */
 private function invokeHandlersForEvent(Event $event) : array
 {
     $room = $event instanceof RoomSourcedEvent ? $event->getRoom() : null;
     $filters = array_merge($this->typeFilteredEventHandlers[$event->getTypeId()] ?? [], $room ? $this->roomFilteredEventHandlers[$room->getIdentifier()->getIdentString()] ?? [] : [], $this->filteredEventHandlers);
     $promises = [];
     foreach ($filters as list($plugin, $filter)) {
         /** @var Filter $filter */
         if (($room === null || $this->isPluginEnabledForRoom($plugin, $room)) && ($promise = $filter->executeForEvent($event))) {
             $promises[] = $promise;
         }
     }
     return $promises;
 }