send message to sessions
apply msgControl to topic
@param sessions
@param mtc
@param payload
@return
17914
int sendMessageToTopicForSessions(Collection<Session> sessions, MessageToClient mtc, Object payload) {
		int sended = 0;
		JsTopicMessageController msgControl = messageControllerManager.getJsTopicMessageController(mtc.getId());
		Collection<Session> sessionsClosed = new ArrayList<>();
		for (Session session : sessions) {
			try {
				sended += checkAndSendMtcToSession(session, msgControl, mtc, payload);
			} catch (SessionException se) {
				sessionsClosed.add(se.getSession());
			}
		}
		if (logger.isDebugEnabled()) {
			logger.debug("Send message to '{}' topic {} client(s) : {}", new Object[]{mtc.getId(), sessions.size() - sessionsClosed.size(), mtc});
		}
		topicManager.removeSessionsToTopic(sessionsClosed);
		return sended;
	}
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);
        }
    }
26937
public void sendBroadcast(CmsObject cms, String message, String sessionId) {

        sendBroadcast(cms, message, sessionId, false);

    }
1042908
@Override
	protected final void sendToDestination(Destination destination, boolean destinationOverride, Message srcMessage, int deliveryMode, int priority, long timeToLive) throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	    	checkNotClosed();
	    	
	    	((RemoteSession)session).dispatch(srcMessage);
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
596187
function deliverMessage (handle, topic, payload) {
  if (handle === 'broadcast') {
    const channel = ChannelsManager.resolve(topic)

    if (!channel) {
      return debug('broadcast topic %s cannot be handled by any channel', topic)
    }

    channel.clusterBroadcast(topic, payload)
    return
  }

  debug('dropping packet, since %s handle is not allowed', handle)
}
824890
private void sendMessages(final List<MessageEnvelope> msgEnvelopes) {
        try {
            boolean success=BackendOperation.execute(new BackendOperation.Transactional<Boolean>() {
                @Override
                public Boolean call(StoreTransaction txh) throws BackendException {
                    ListMultimap<StaticBuffer,Entry> mutations = ArrayListMultimap.create();
                    for (MessageEnvelope env : msgEnvelopes) {
                        mutations.put(env.key,env.entry);
                        long ts = env.entry.getColumn().getLong(0);
                        log.debug("Preparing to write {} to storage with column/timestamp {}", env, times.getTime(ts));
                    }

                    Map<StaticBuffer,KCVMutation> muts = new HashMap<StaticBuffer, KCVMutation>(mutations.keySet().size());
                    for (StaticBuffer key : mutations.keySet()) {
                        muts.put(key,new KCVMutation(mutations.get(key),KeyColumnValueStore.NO_DELETIONS));
                        log.debug("Built mutation on key {} with {} additions", key, mutations.get(key).size());
                    }
                    manager.storeManager.mutateMany(ImmutableMap.of(store.getName(),muts),txh);
                    log.debug("Wrote {} total envelopes with operation timestamp {}", msgEnvelopes.size(), txh.getConfiguration().getCommitTime());
                    return Boolean.TRUE;
                }
                @Override
                public String toString() {
                    return "messageSending";
                }
            },this, times, maxWriteTime);
            Preconditions.checkState(success);
            log.debug("Wrote {} messages to backend",msgEnvelopes.size());
            for (MessageEnvelope msgEnvelope : msgEnvelopes)
                msgEnvelope.message.delivered();
        } catch (TitanException e) {
            for (MessageEnvelope msgEnvelope : msgEnvelopes)
                msgEnvelope.message.failed(e);
            throw e;
        }
    }
1368091
@Override
    public void onMessage(Message message, Session session) throws JMSException {

        StandardLogger logger = LoggerUtil.getStandardLogger();
        try {
            String txt = ((TextMessage) message).getText();
            if (logger.isDebugEnabled()) {
                logger.debug("JMS Spring ExternalEvent Listener receives request: " + txt);
            }
            String resp;
            ListenerHelper helper = new ListenerHelper();
            Map<String, String> metaInfo = new HashMap<String, String>();
            metaInfo.put(Listener.METAINFO_PROTOCOL, Listener.METAINFO_PROTOCOL_JMS);
            metaInfo.put(Listener.METAINFO_REQUEST_PATH, ((Queue)message.getJMSDestination()).getQueueName());
            metaInfo.put(Listener.METAINFO_SERVICE_CLASS, this.getClass().getName());
            metaInfo.put(Listener.METAINFO_REQUEST_ID, message.getJMSMessageID());
            metaInfo.put(Listener.METAINFO_CORRELATION_ID, message.getJMSCorrelationID());
            if (message.getJMSReplyTo() != null)
                metaInfo.put("ReplyTo", message.getJMSReplyTo().toString());

            resp = helper.processEvent(txt, metaInfo);
            String correlId = message.getJMSCorrelationID();

            Queue respQueue = (Queue) message.getJMSReplyTo();
            if (resp != null && respQueue != null) {
                mdwMessageProducer.sendMessage(resp, respQueue, correlId);
                if (logger.isDebugEnabled()) {
                    logger.debug("JMS Listener sends response (corr id='" + correlId + "'): "
                            + resp);
                }

            }

        }
        catch (Throwable ex) {
            logger.severeException(ex.getMessage(), ex);
        }

    }
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);
        }
    }
1160120
@Override
    public void sendNackMessage(
                                SIBUuid8 upstream,
                                SIBUuid12 destUuid,
                                SIBUuid8 busUuid,
                                long startTick,
                                long endTick,
                                int priority,
                                Reliability reliability,
                                SIBUuid12 stream) throws SIResourceException
    {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "sendNackMessage",
                        new Object[] { new Long(startTick), new Long(endTick) });

        ControlNack nackMsg = createControlNackMessage(priority, reliability, stream);

        nackMsg.setStartTick(startTick);
        nackMsg.setEndTick(endTick);

        if (upstream == null)
        {
            upstream = _originStreamMap.get(stream);
        }

        // Send this to MPIO
        // Send Nack messages at message priority +2
        _mpio.sendToMe(
                       upstream,
                       priority + 2,
                       nackMsg);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "sendNackMessage ");
    }
1296343
def send(self, from_client, message, to_clients=None, transient=False, push_data=None):
        
        if isinstance(message, dict):
            message = json.dumps(message)
        params = {
            'from_peer': from_client,
            'conv_id': self.id,
            'transient': transient,
            'message': message,
        }
        if to_clients:
            params['to_peers'] = to_clients
        if push_data:
            params['push_data'] = push_data
        client.post('/rtm/messages', params=params).json()
758958
private void sendMessage(BeanMessageID type, Buffer payload) {
        Buffer buffer = new Buffer();
        buffer.writeByte((type.getRawValue() >> 8) & 0xff);
        buffer.writeByte(type.getRawValue() & 0xff);
        if (payload != null) {
            try {
                buffer.writeAll(payload);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        GattSerialMessage serialMessage = GattSerialMessage.fromPayload(buffer.readByteArray());
        gattClient.getSerialProfile().sendMessage(serialMessage.getBuffer());
    }
326354
@Override
	public synchronized TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException
    {
        checkNotClosed();
        LocalTopicSession session =  new LocalTopicSession(idProvider.createID(),this,engine,transacted,acknowledgeMode);
        registerSession(session);
        return session;
    }
541300
private void updateSession(final LinkedHashMap<String, XMLObject> messages) {
        context.getSessionStore().set(context, SAML_STORAGE_KEY, messages);
    }
942782
public static List<WriteFuture> broadcast(Object message, Collection<IoSession> sessions) {
        List<WriteFuture> answer = new ArrayList<>(sessions.size());
        broadcast(message, sessions.iterator(), answer);
        return answer;
    }
1274201
public static List<WriteFuture> broadcast(Object message, Iterable<IoSession> sessions) {
        List<WriteFuture> answer = new ArrayList<>();
        broadcast(message, sessions.iterator(), answer);
        return answer;
    }
1281494
public void onMessage(Mtp2Buffer rxFrame, Mtp2 mtp2) {
        // | ----------------------- TO L4 --------------------------- |
        // | --------------------- SIF ------------------------ |
        // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
        // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
        int sio = rxFrame.frame[3] & 0xFF;
        int subserviceIndicator = (sio >> 4) & 0x0F;
        int serviceIndicator = sio & 0x0F;
        int ni = (subserviceIndicator & 0x0C); // local NI(network Indicator) form msg., 0x0C, since we store it as shifted
                                               // value.
        // int dpc = (sif[0] & 0xff | ((sif[1] & 0x3f) << 8));
        // int opc = ((sif[1] & 0xC0) >> 6) | ((sif[2] & 0xff) << 2) | ((sif[3]
        // & 0x0f) << 10);
        // int sls = (sif[3] & 0xf0) >>> 4;
        int dpc = dpc(rxFrame.frame, 4); // 1 - cause sif contains sio, even though its also passed as arg.
        int opc = opc(rxFrame.frame, 4);
        int sls = sls(rxFrame.frame, 4);

        // check SSI, Q.704 Figure 25, seems like if its bad, we discard.
        if (this.ni != ni) {
            if (logger.isEnabledFor(Level.ERROR)) {
                logger.error(String.format("(%s) Received MSSU with bad SSI, discarding! ni:" + ni + " thisni:" + this.ni
                        + " [si=" + serviceIndicator + ",ssi=" + subserviceIndicator + ", dpc=" + dpc + ", opc=" + opc
                        + ", sls=" + sls + "] data: ", mtp2.getName())
                        + Arrays.toString(rxFrame.frame));
            }
            return;
        }

        switch (serviceIndicator) {
            case LINK_MANAGEMENT:
                int h0 = rxFrame.frame[8] & 0x0f;
                int h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                if (logger.isDebugEnabled()) {
                    logger.debug(String.format("(%s) Signalling network management", mtp2.getName()));
                }

                if (h0 == 0) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Changeover management", mtp2.getName()));
                    }
                } else if (h0 == 7 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) TRA received", mtp2.getName()));
                    }
                }
                // FIX ME
                break;
            case LINK_TESTING:
                h0 = rxFrame.frame[8] & 0x0f;
                h1 = (rxFrame.frame[8] & 0xf0) >>> 4;

                int len = (rxFrame.frame[9] & 0xf0) >>> 4;
                if (h0 == 1 && h1 == 1) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTM", mtp2.getName()));
                    }
                    // receive SLTM from remote end
                    // create response

                    // change order of opc/dpc in SLTA !
                    writeRoutingLabel(this.localFrame, sio, this.ni, sls, opc, dpc);
                    // slta[0] = (byte) sio;
                    this.localFrame[5] = 0x021;
                    // +1 cause we copy LEN byte also.
                    System.arraycopy(rxFrame.frame, 9, this.localFrame, 6, len + 1);

                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Responding with SLTA", mtp2.getName()));
                    }
                    mtp2.send(this.localFrame, len + 9);
                } else if (h0 == 1 && h1 == 2) {
                    // receive SLTA from remote end
                    if (logger.isDebugEnabled()) {
                        logger.debug(String.format("(%s) Received SLTA", mtp2.getName()));
                    }

                    // checking pattern
                    if (checkPattern(rxFrame, len, SLTM_PATTERN)) {
                        // test message is acknowledged
                        mtp2.sltmTest.ack();

                        // notify top layer that link is up
                        if (!l4IsUp) {
                            l4IsUp = true;
                            linkUp(mtp2);
                        }
                    } else {
                        if (logger.isEnabledFor(Level.WARN)) {
                            logger.warn("SLTA pattern does not match: \n" + Arrays.toString(rxFrame.frame) + "\n"
                                    + Arrays.toString(SLTM_PATTERN));
                        }
                    }
                } else {
                    if (logger.isEnabledFor(Level.WARN)) {
                        logger.warn(String.format("(%s) Unexpected message type", mtp2.getName()));
                    }
                }
                break;
            case _SI_SERVICE_SCCP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received SCCP MSU");
                }

                if (mtp3Listener != null) {

                    // | ----------------------- TO L4 --------------------------- |
                    // | --------------------- SIF ------------------------ |
                    // FSN BSN LEN SIO DPC/OPC,SLS HEADING LEN
                    // b1 b0 0e 01 01 80 00 00 21 70 01 02 03 04 05 06 0f CRC CRC
                    byte[] messageBuffer = new byte[rxFrame.len - 5]; // -5 = FSN(1) + BSN(1) + LEN(1) +2xCRC(1)
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            case _SI_SERVICE_ISUP:
                if (logger.isDebugEnabled()) {
                    logger.debug("Received ISUP MSU");

                }
                if (mtp3Listener != null) {
                    byte[] messageBuffer = new byte[rxFrame.len - 5];
                    System.arraycopy(rxFrame.frame, 3, messageBuffer, 0, rxFrame.len - 5);
                    // messageBuffer[0] = (byte) sio;
                    try {
                        mtp3Listener.receive(messageBuffer);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                break;
            default:
                if (logger.isEnabledFor(Level.WARN)) {
                    logger.warn("Received MSU for UNKNOWN SERVICE!!!!!!!!!!!: " + Utils.dump(rxFrame.frame, rxFrame.len, false));
                }
                break;
        }
    }
937026
public void send(RoxPayload payload) {		
		try {
			if (isStarted()) {
				ByteArrayOutputStream baos = new ByteArrayOutputStream();

				new JsonSerializer().serializePayload(new OutputStreamWriter(baos), payload, false);

				socket.emit("payload", new String(baos.toByteArray()));
			}
			else {
				LOGGER.warn("Minirox is not available to send the test results");
			}
		}
		catch (Exception e) {
			LOGGER.warn("Unable to send the result to MINI ROX. Cause: {}", e.getMessage());
			
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("Exception: ", e);
			}
		}
	}