Send a command to multiple targets.

Doesn't send the command to itself unless {@code deliverOrder == TOTAL}.
320877
private void sendCommand(Collection<Address> targets, ReplicableCommand command, long requestId,
                            DeliverOrder deliverOrder, boolean rsvp, boolean checkView) {
      Objects.requireNonNull(targets);
      Message message = new Message();
      marshallRequest(message, command, requestId);
      setMessageFlags(message, deliverOrder, rsvp, true);

      if (deliverOrder == DeliverOrder.TOTAL) {
         message.dest(new AnycastAddress(toJGroupsAddressList(targets)));
         send(message);
      } else {
         Message copy = message;
         for (Iterator<Address> it = targets.iterator(); it.hasNext(); ) {
            Address address = it.next();

            if (checkView && !clusterView.contains(address))
               continue;

            if (address.equals(getAddress()))
               continue;

            copy.dest(toJGroupsAddress(address));
            send(copy);

            // Send a different Message instance to each target
            if (it.hasNext()) {
               copy = copy.copy(true);
            }
         }
      }
   }
216964
def send(self, op, cmd, integration_id, *args):
    """"""
    out_cmd = ",".join(
        (cmd, str(integration_id)) + tuple((str(x) for x in args)))
    self._conn.send(op + out_cmd)
1119251
private void deliver() {
    // We can have reentrancy here when using a direct executor, triggered by calls to
    // request more messages. This is safe as we simply loop until pendingDelivers = 0
    if (inDelivery) {
      return;
    }
    inDelivery = true;
    try {
      // Process the uncompressed bytes.
      while (!stopDelivery && pendingDeliveries > 0 && readRequiredBytes()) {
        switch (state) {
          case HEADER:
            processHeader();
            break;
          case BODY:
            // Read the body and deliver the message.
            processBody();

            // Since we've delivered a message, decrement the number of pending
            // deliveries remaining.
            pendingDeliveries--;
            break;
          default:
            throw new AssertionError("Invalid state: " + state);
        }
      }

      if (stopDelivery) {
        close();
        return;
      }

      /*
       * We are stalled when there are no more bytes to process. This allows delivering errors as
       * soon as the buffered input has been consumed, independent of whether the application
       * has requested another message.  At this point in the function, either all frames have been
       * delivered, or unprocessed is empty.  If there is a partial message, it will be inside next
       * frame and not in unprocessed.  If there is extra data but no pending deliveries, it will
       * be in unprocessed.
       */
      if (closeWhenComplete && isStalled()) {
        close();
      }
    } finally {
      inDelivery = false;
    }
  }
387866
protected void executeSendCommandWithNoResponse(SendCommandTask task)
        throws PDUException, IOException {

        int seqNum = sequence.nextValue();
        try {
            task.executeTask(connection().getOutputStream(), seqNum);
        } catch (IOException e) {
            logger.error("Failed sending " + task.getCommandName() + " command", e);
            close();
            throw e;
        }
    }
1254703
def send_command(self, command, arg=None):
    
    if arg is not None:
      command = '%s:%s' % (command, arg)
    self._write(six.StringIO(command), len(command))
1330263
protected void doExecuteCommand() {
        if (this.commandExecutor instanceof ParameterizableActionCommandExecutor) {
            ((ParameterizableActionCommandExecutor) this.commandExecutor).execute(getParameters());
        }
        else {
        	if (this.commandExecutor != null) {
        		this.commandExecutor.execute();
        	}
        }
    }
506031
public void deliver(final byte[] message) {
    synchronized (this.heartBeatManager) {
      if (this.currentStatus.isNotRunning()) {
        LOG.log(Level.WARNING,
            "Trying to send a message to a task that is in state: {0}. Ignoring.",
            this.currentStatus.getState());
      } else {
        try {
          this.deliverMessageToTask(message);
        } catch (final TaskMessageHandlerFailure taskMessageHandlerFailure) {
          LOG.log(Level.WARNING, "Exception while executing task close handler.",
              taskMessageHandlerFailure.getCause());
          this.currentStatus.setException(taskMessageHandlerFailure.getCause());
        }
      }
    }
  }
1268761
def send_command(self, data, read_delay=None):
        """"""
        self._write(data)
        if read_delay:
            time.sleep(read_delay)
        return self._read()
228877
@Override
	public void sendCommand(final BitfinexCommand command) {
		try {
			if (command instanceof BitfinexStreamSymbolToChannelIdResolverAware) {
				final BitfinexStreamSymbolToChannelIdResolverAware aware = (BitfinexStreamSymbolToChannelIdResolverAware) command;
				aware.setResolver(symbol -> {
					final Integer channelId = getChannelForSymbol(symbol);
					if (channelId == null) {
						throw new IllegalArgumentException("Unknown symbol: " + symbol);
					}
					return channelId;
				});
			}
			final String json = command.getCommand(this);
            logger.debug("Sent: {}", command);
			websocketEndpoint.sendMessage(json);
		} catch (final BitfinexCommandException e) {
			logger.error("Got Exception while sending command", e);
		}
	}
994854
function onCommand(cmd, args) {

  if(cmd === Constants.MAP.multi.name) {
    return this._abort(new Error('multi transaction cannot be nested'));
  }

  if(cmd === Constants.MAP.watch.name) {
    return this._abort(
      new Error('watch should be executed before a multi transaction'));
  }

  if(!this._client || !Array.isArray(this._queue)) {
    throw new Error('multi transaction already aborted');
  }

  function doExec(cmd, args, cb) {
    this._client.execute(cmd, args, cb);
  }

  doExec = doExec.bind(this);

  function onComplete(cmd, args, err, reply) {

    if(typeof args[0] === 'function') {
      args[0](err, reply);
    }else{
      this._client.emit('exec', err, reply);
    }

    // reset, this multi can be re-used
    this._reset();
  }

  function onQueue(cmd, args, err, reply) {
    this._queue.push(err || reply);

    var next = this._commands.shift();
    /* istanbul ignore else */
    if(next) {
      // executing a command
      if(next.cmd !== Constants.MAP.exec.name) {
        doExec(next.cmd, next.args, onQueue.bind(this, next.cmd, next.args));
      // running the exec command to get the result
      }else{
        doExec(next.cmd, [], onComplete.bind(this, cmd, next.args));
      }
    }
  }

  // send first multi packet
  if(!this._multi) {
    doExec(
      this._commands[0].cmd,
      this._commands[0].args,
      onQueue.bind(
        this,
        this._commands[0].cmd, []));

    // clear multi packet
    this._commands = [];
    this._multi = true;
  }

  // stash the command in a queue
  this._commands.push({cmd: cmd, args: args});
}
885368
public List<Command> receive(final Command command) {

        Assert.requireNonNull(command, "command");
        LOG.trace("Received command of type {}", command.getClass().getSimpleName());
        List<Command> response = new LinkedList();// collecting parameter pattern

        if (!(command instanceof InterruptLongPollCommand)) {// signal commands must not update thread-confined state
            for (DolphinServerAction it : dolphinServerActions) {
                it.setDolphinResponse(response);// todo: can be deleted as soon as all action refer to the SMS
            }

            serverModelStore.setCurrentResponse(response);
        }


        List<CommandHandler> actions = registry.getActionsFor(command.getClass());
        if (actions.isEmpty()) {
            LOG.warn("There is no server action registered for received command type {}, known commands types are {}", command.getClass().getSimpleName(), registry.getActions().keySet());
            return response;
        }

        // copying the list of actions allows an Action to unregister itself
        // avoiding ConcurrentModificationException to be thrown by the loop
        List<CommandHandler> actionsCopy = new ArrayList<CommandHandler>();
        actionsCopy.addAll(actions);
        try {
            for (CommandHandler action : actionsCopy) {
                action.handleCommand(command, response);
            }

        } catch (Exception exception) {
            throw exception;
        }

        return response;
    }
1070107
def send(self, command, sender, target, args, kwargs):
        
        command = get_command(command)
        data = {'command': command.__name__,
                'id': create_aid(),
                'sender': actor_identity(sender),
                'target': actor_identity(target),
                'args': args if args is not None else (),
                'kwargs': kwargs if kwargs is not None else {}}

        waiter = self._loop.create_future()
        ack = None
        if command.ack:
            ack = create_aid()
            data['ack'] = ack
            self.pending_responses[ack] = waiter

        try:
            self.write(data)
        except Exception as exc:
            waiter.set_exception(exc)
            if ack:
                self.pending_responses.pop(ack, None)
        else:
            if not ack:
                waiter.set_result(None)
        return waiter
1005347
function deliverMessage (message) {
  workerIterator((worker) => {
    if (this.process.pid === worker.process.pid) {
      return
    }
    debug('delivering message to %s', worker.process.pid)
    worker.send(message)
  })
}
1082468
private void deliver() {
    try {
      deliverUnsafe();
    } catch (Throwable t) {
      // This should never happen. If does, it means we are in an inconsistent state and should
      // close the stream and further processing should be prevented. This is accomplished by
      // purposefully leaving the lock non-zero and notifying the outerResponseObserver of the
      // error. Care must be taken to avoid calling close twice in case the first invocation threw
      // an error.
      innerController.cancel();
      if (!finished) {
        outerResponseObserver.onError(t);
      }
    }
  }
74754
private void deliverFaderStartCommand(Set<Integer> playersToStart, Set<Integer> playersToStop) {
        for (final FaderStartListener listener : getFaderStartListeners()) {
            try {
                listener.fadersChanged(playersToStart, playersToStop);
            } catch (Throwable t) {
                logger.warn("Problem delivering fader start command to listener", t);
            }
        }
    }
990795
function sendCommand(method, url, payload, skipQueue) {
    if (!self.connected) {
      debug('Queueing %s %s', method, url);
      return new P(function(resolve, reject) {
        var p = P.method(function() {
          debug('Dequeueing %s %s', method, url);
          return _sendCommand(method, url, payload)
            .then(resolve)
            .catch(reject);
        });
        if (skipQueue) {
          pendingCommands.splice(0, 0, p);
        } else {
          pendingCommands.push(p);
        }
      });
    }
    return _sendCommand(method, url, payload);
  }
1209315
@SuppressWarnings("checkstyle:illegalcatch")
  private void deliverMessageToTask(final byte[] message) throws TaskMessageHandlerFailure {
    try {
      this.fMessageHandler.get().onNext(new DriverMessageImpl(message));
    } catch (final Throwable throwable) {
      throw new TaskMessageHandlerFailure(throwable);
    }
  }