STOMP send command.

    dest:
        This is the channel we wish to subscribe to

    msg:
        This is the message body to be sent.

    transactionid:
        This is an optional field and is not needed
        by default.
519759
def send(dest, msg, transactionid=None):
    
    transheader = ''

    if transactionid:
        transheader = 'transaction: %s\n' % transactionid

    return "SEND\ndestination: %s\n%s\n%s\x00\n" % (dest, transheader, msg)
1170388
function _cmdSend(idOrArray, msgStr) {
    if (!Array.isArray(idOrArray)) {
        idOrArray = [idOrArray];
    }
    idOrArray.forEach(function (id) {
        var client = _clients[id];
        if (!client) {
            console.error("nodeSocketTransport: Couldn't find client ID: " + id);
        } else {
            client.socket.send(msgStr);
        }
    });
}
1007512
@Override
    public ListenableFuture<Void> submitCommand(Command command) throws NotLeaderException {
        checkState(running); // implies conversion setup and initialization happened

        // since access to raftAlgorithm is not serialized
        // here it's possible for raftAlgorithm to be stopped
        // by one thread in the time between a caller thread
        // doing a successful check above and calling submitCommand
        // below, triggering an ISE. I judge this acceptable.
        // The alternative is serializing access to raftAlgorithm here
        // (raftAlgorithm methods themselves are serialized) and
        // holding yet another lock while calling into raftAlgorithm

        return raftAlgorithm.submitCommand(command);
    }
261545
def send(self, message):
        
        self.logger.debug('Send message: {}'.format(message))

        if self.state == 'pending' or self.state == 'connection_pending':
            self.logger.info('Connection not established. Add message to queue.')
            self.message_queue.append(message)
            return
        elif self.state == 'unsubscribed' or self.state == 'rejected':
            self.logger.warning('Not subscribed! Message discarded.')
            return

        data = {
            'command': 'message',
            'identifier': self._identifier_string(),
            'data': message.raw_message()
        }

        self.connection.send(data)
684942
async def request(self, request, addr, integrity_key=None, retransmissions=None):
        
        assert request.transaction_id not in self.transactions

        if integrity_key is not None:
            request.add_message_integrity(integrity_key)
            request.add_fingerprint()

        transaction = stun.Transaction(request, addr, self, retransmissions=retransmissions)
        transaction.integrity_key = integrity_key
        self.transactions[request.transaction_id] = transaction
        try:
            return await transaction.run()
        finally:
            del self.transactions[request.transaction_id]
896805
public static void main(String[] args){

        // Listeners are subscribed by passing them to the #subscribe() method
        bus.subscribe(new ListenerDefinition.SyncAsyncListener());

        // #subscribe() is idem-potent => Multiple calls to subscribe do NOT add the listener more than once (set semantics)
        Object listener = new ListenerDefinition.SyncAsyncListener();
        bus.subscribe(listener);
        bus.subscribe(listener);

        // Classes without handlers will be silently ignored
        bus.subscribe(new Object());
        bus.subscribe(new String());

        bus.publishAsync(new File("/tmp/random.csv")); //returns immediately, publication will continue asynchronously
        bus.post(new File("/tmp/random.csv")).asynchronously(); // same as above

        bus.publish("some message");   // will return after each handler has been invoked
        bus.post("some message").now(); // same as above


    }
1364574
@Override
  public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
    final ByteBuf message = (ByteBuf) msg;
    final byte magic = message.getByte(0);

    // The majority of messages are likely to be stream requests, not responses.
    if (magic != MessageUtil.MAGIC_RES) {
      handleRequest(ctx, message);
      return;
    }

    // "The current protocol dictates that the server won't start
    // processing the next command until the current command is completely
    // processed (due to the lack of barriers or any other primitives to
    // enforce execution order). The protocol defines some "quiet commands"
    // which won't send responses in certain cases (success for mutations,
    // not found for gets etc). The client would know that such commands
    // was executed when it encounters the response for the next command
    // requested issued by the client."
    // -- https://github.com/couchbase/memcached/blob/master/docs/BinaryProtocol.md#introduction-1

    // The DCP client does not send any "quiet commands", so we assume
    // a 1:1 relationship between requests and responses, and FIFO order.
    final OutstandingRequest request = outstandingRequests.poll();
    if (request == null || MessageUtil.getOpaque(message) != request.opaque) {
      // Should never happen so long as all requests are made via sendRequest()
      // and successfully written to the channel.
      LOGGER.error("Unexpected response with opaque {} (expected {}); closing connection",
          MessageUtil.getOpaque(message), request == null ? "none" : request.opaque);
      ctx.close();
      return;
    }

    request.promise.setSuccess(new DcpResponse(message));
  }
867557
protected void broadcastTo (
        DObject object, Name from, byte levelOrMode, String bundle, String msg)
    {
        if (from == null) {
            SpeakUtil.sendSystem(object, bundle, msg, levelOrMode /* level */);

        } else {
            SpeakUtil.sendSpeak(object, from, bundle, msg, levelOrMode /* mode */);
        }
    }
254590
public void send(Command command) {
    logger.finest(command.toString());
    byte[] payload = command.toByteArray();
    int totalSize = payload.length + 1; // increment 1 for message type

    ByteBuffer outMessageSize = encodeMessageSize(totalSize);

    // create the message
    ByteBuffer buffer = ByteBuffer.allocateDirect(prefix.length
                                                  + outMessageSize.position() + 1 + payload.length);
    buffer.put(prefix, 0, prefix.length);
    outMessageSize.flip();
    buffer.put(outMessageSize);
    buffer.put((byte) 1);
    buffer.put(payload);

    // Log what is being sent.
    logger.finest("SEND: " + command);

    requests.add(buffer);
    monitor.modify(socketChannel, this, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
  }
448041
function subscribeToChat () {
  console.tron.log('Subscribing to Chat')
  if (!subscriptions.hasOwnProperty('chat')) {
    subscriptions.chat = { subscribed: true }
    connection.then(() => {
      chatSubscriber = stompClient.subscribe('/topic/chat', onMessage.bind(this, 'chat'))
    })
  }
}
1306832
public MessageId send(ProducerConnectionContext context, BasicMessage basicMessage) throws JMSException {
        return send(context, basicMessage, null);
    }
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);
        }
    }
365556
def process_message(self,msg,sock):
    ""
    command=msg[0]
    try: f={'GET':self.get,'SET':self.set,'SUBSCRIBE':self.sub,'PUBLISH':self.pub,
      'PING':self.ping,'GETSET':self.getset,'EXPIRE':self.expire,'DEL':self.delete}[command]
    except KeyError: print msg; raise
    args=msg[1:]
    try: return f(sock,*args) if command in self.SOCK_COMMANDS else f(*args)
    except Exception as e:
      print e
      print msg
      return '-ERROR\r\n'
208926
void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
        Log.trace("processUnsubscribe invoked, removing subscription on topics {}, for clientID <{}>", topics, clientID);

        for (String topic : topics) {
            subscriptions.removeSubscription(topic, clientID);
        }
        //ack the client
        UnsubAckMessage ackMessage = new UnsubAckMessage();
        ackMessage.setMessageID(messageID);

        Log.trace("replying with UnsubAck to MSG ID {}", messageID);
        session.write(ackMessage);
    }
123609
def connected(self, msg):
        
        stomper.Engine.connected(self, msg)

        self.log.info("Connected: session %s. Beginning say hello." % msg['headers']['session'])
        
        def setup_looping_call():
            lc = LoopingCall(self.send)
            lc.start(2)
            
        reactor.callLater(1, setup_looping_call)

        f = stomper.Frame()
        f.unpack(stomper.subscribe(DESTINATION))

        # ActiveMQ specific headers:
        #
        # prevent the messages we send comming back to us.
        f.headers['activemq.noLocal'] = 'true'
        
        return f.pack()
986620
protected void sendMessage(String dest, Message message) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Sends message {} to {}.",
                TextFormat.shortDebugString(message),
                dest);
    }
    this.transport.send(dest, message);
  }
440123
@Override
    public void send(Message msg) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "send", msg);

        //Defer straight through to the version with completion listner (which will do all the locking and checking).
        send_internal(msg, null);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "send");
    }