Send an Event Message for each subscription
@param Session $session
@param PublishMessage $msg
@param Subscription $subscription
193856
private function sendEventMessage(Session $session, PublishMessage $msg, Subscription $subscription)
    {
        $sessionId             = $subscription->getSession()->getSessionId();
        $authroles             = [];
        $authid                = '';
        $authenticationDetails = $subscription->getSession()->getAuthenticationDetails();
        if ($authenticationDetails) {
            $authroles = $authenticationDetails->getAuthRoles();
            $authid    = $authenticationDetails->getAuthId();
        }

        if ((!$msg->excludeMe() || $subscription->getSession() != $session)
            && !$msg->isExcluded($sessionId)
            && $msg->isWhiteListed($sessionId)
            && $msg->hasEligibleAuthrole($authroles)
            && $msg->hasEligibleAuthid($authid)
        ) {
            $eventMsg = EventMessage::createFromPublishMessage($msg, $subscription->getId());
            if ($subscription->isDisclosePublisher() === true) {
                $eventMsg->disclosePublisher($session);
            }
            if ($this->getMatchType() !== 'exact') {
                $eventMsg->getDetails()->topic = $msg->getUri();
            }
            $subscription->sendEventMessage($eventMsg);
        }
    }
721079
private function processError(Session $session, ErrorMessage $msg)
    {
        switch ($msg->getErrorMsgCode()) {
            case Message::MSG_INVOCATION:
                $this->processInvocationError($session, $msg);
                break;
            case Message::MSG_INTERRUPT:
                $this->processInterruptError($session, $msg);
                break;
        }
    }
835528
void sendSubscriptionEvent(String topic, int nb) {
		Collection<Session> sessions = getSessionsForTopic(topic);
		if (!sessions.isEmpty()) {
			MessageToClient messageToClient = new MessageToClient();
			messageToClient.setId(topic);
			messageToClient.setType(MessageType.MESSAGE);
			messageToClient.setResponse(nb);
//			Collection<Session> sessionsClosed = new ArrayList<>(); // throws java.lang.StackOverflowError
			for (Session session : sessions) {
				if (session.isOpen()) {
					session.getAsyncRemote().sendObject(messageToClient);
//				} else {
//					sessionsClosed.add(session);
				}
			}
//			removeSessionsToTopic(sessionsClosed);
		}
	}
639399
public void send(final Command msg) throws HandlerSocketException {
		Session session = this.selectSession();
		session.write(msg);
	}
98913
public function basicPublish( \AMQP\Message $msg, $options = array())
    {
        $default = array('exchange' => '', 'routing_key' => '', 'mandatory' => false, 'immediate' => false,
                         'ticket' => null);
        $options = array_merge($default, $options);
        $options['ticket'] = $this->getTicket($options['ticket']);
        $args = $this->frameBuilder->basicPublish($options);

        $this->sendMethodFrame(array(60, 40), $args);

        $this->connection->sendContent(
            $this->channelId, 60, 0,
            strlen($msg->body),
            $msg->serializeProperties(),
            $msg->body
        );
    }
233202
protected function invokeSubscription(IEventSubscription $subscription, IEvent $event) {
        foreach ($this->invokers as $invoker) {
            if ($invoker->invoke($subscription, $event)) {
                return;
            }
        }

        $subscriber = $subscription->getSubscriber();

        throw new Exception(
            s('Could not invoke subscriber "%s".',
                is_scalar($subscriber) ? $subscriber : get_type($subscriber))
        );
    }
284810
public function handleAuthenticateMessage(Realm $realm, Session $session, AuthenticateMessage $msg)
    {
        if ($session->getAuthenticationDetails() === null) {
            throw new \Exception('Authenticate with no previous auth details');
        }

        $authMethod = $session->getAuthenticationDetails()->getAuthMethod();

        // find the auth method
        foreach ($this->authMethods as $am => $authMethodInfo) {
            if ($authMethod == $am) {
                $this->onAuthenticateHandler($authMethod, $authMethodInfo, $realm, $session, $msg);
            }
        }
    }
563245
public void sendMessage(final String message) {
		if(userSession == null) {
			logger.error("Unable to send message, user session is null");
			return;
		}
		if(userSession.getAsyncRemote() == null) {
			logger.error("Unable to send message, async remote is null");
			return;
		}
		userSession.getAsyncRemote().sendText(message);
	}
1342203
public function broadcast(GraphQLSubscription $subscription, string $fieldName, $root): void
    {
        $topic = $subscription->decodeTopic($fieldName, $root);

        $subscribers = $this->storage
            ->subscribersByTopic($topic)
            ->filter(function (Subscriber $subscriber) use ($subscription, $root): bool {
                return $subscription->filter($subscriber, $root);
            });

        $this->iterator->process(
            $subscribers,
            function (Subscriber $subscriber) use ($root): void {
                $data = $this->graphQL->executeQuery(
                    $subscriber->query,
                    $subscriber->context,
                    $subscriber->args,
                    $subscriber->setRoot($root),
                    $subscriber->operationName
                );

                $this->broadcastManager->broadcast(
                    $subscriber,
                    $data->jsonSerialize()
                );
            }
        );
    }
1093626
public function processUnregister(Session $session, UnregisterMessage $msg)
    {
        for ($i = 0; $i < count($this->registrations); $i++) {
            /** @var Registration $registration */
            $registration = $this->registrations[$i];
            if ($registration->getId() == $msg->getRegistrationId()) {

                // make sure the session is the correct session
                if ($registration->getSession() !== $session) {
                    $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_registration'));
                    //$this->manager->warning('Tried to unregister a procedure that belongs to a different session.');
                    return false;
                }

                array_splice($this->registrations, $i, 1);

                // TODO: need to handle any calls that are hanging around

                $session->sendMessage(UnregisteredMessage::createFromUnregisterMessage($msg));
                return true;
            }
        }

        $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_registration'));

        return false;
    }
1012898
public function triggerSubscriptionChanged(GatewayInterface $gateway, SubscriptionInterface $subscription, ChangeInterface $change)
    {
        $this->trigger(self::ON_SUBSCRIPTION_CHANGED, $gateway, $subscription, $change);
    }
724951
@Override
	public final void publish(Topic topic, Message message) throws JMSException
    {
        send(topic,message);
    }
832563
private function processUnregister(Session $session, UnregisterMessage $msg)
    {
        $registration = $this->getRegistrationById($msg->getRegistrationId());

        if ($registration && $this->procedures[$registration->getProcedureName()]) {
            $procedure = $this->procedures[$registration->getProcedureName()];
            if ($procedure) {
                if ($procedure->processUnregister($session, $msg)) {
                    // Unregistration was successful - remove from this sessions
                    // list of registrations
                    if ($this->registrationsBySession->contains($session) &&
                        in_array($procedure, $this->registrationsBySession[$session], true)
                    ) {
                        $registrationsInSession = $this->registrationsBySession[$session];
                        array_splice($registrationsInSession, array_search($procedure, $registrationsInSession, true), 1);
                    }
                }
            }

            return;
        }

        // apparently we didn't find anything to unregister
        $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_procedure'));
    }
870858
public function reply(Client $client, MessageInterface $msg)
    {
        $this->getStream('client')->send($msg, $client->getId());
        $this->remove($client);
    }
860510
private function toSession ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true)
		{
			$ntf = new Notification($message, $type, $isRaw, $canHide);

			$notification = isset($_SESSION[ 'notification' ]) ? $_SESSION[ 'notification' ] : [];
			$notification[ $type ][] = $ntf->message;

			$_SESSION[ 'notification' ] = $notification;
		}
1170551
public void send(Destination dest, Message msg) throws MessagingException {
        try {
            Session s =
                    connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer p = s.createProducer(dest);
            p.send(msg);
            s.close();
        } catch (JMSException e) {
            throw new MessagingException(e.getMessage(), e);
        }

        if(logger.isDebugEnabled()) {
            logger.debug("send() - message sent to destination " + dest);
        }
    }
383950
public function saveMessage($msg)
    {
	$messages = $this->session->get("FlashInSession", []);
	$messages[] = $msg;
	$this->session->set("FlashInSession", $messages);
    }