gpt4 book ai didi

org.zeromq.ZMsg.send()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 21:36:49 26 4
gpt4 key购买 nike

本文整理了Java中org.zeromq.ZMsg.send()方法的一些代码示例,展示了ZMsg.send()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZMsg.send()方法的具体详情如下:
包路径:org.zeromq.ZMsg
类名称:ZMsg
方法名:send

ZMsg.send介绍

[英]Send message to 0MQ socket.
[中]将消息发送到0MQ套接字。

代码示例

代码示例来源:origin: twosigma/beakerx

private synchronized void sendMsg(ZMQ.Socket socket, List<Message> messages) {
 if (!isShutdown()) {
  messages.forEach(message -> {
   String header = toJson(message.getHeader());
   String parent = toJson(message.getParentHeader());
   String meta = toJson(message.getMetadata());
   String content = toJson(message.getContent());
   String digest = hmac.sign(Arrays.asList(header, parent, meta, content));
   ZMsg newZmsg = new ZMsg();
   message.getIdentities().forEach(newZmsg::add);
   newZmsg.add(DELIM);
   newZmsg.add(digest.getBytes(StandardCharsets.UTF_8));
   newZmsg.add(header.getBytes(StandardCharsets.UTF_8));
   newZmsg.add(parent.getBytes(StandardCharsets.UTF_8));
   newZmsg.add(meta.getBytes(StandardCharsets.UTF_8));
   newZmsg.add(content.getBytes(StandardCharsets.UTF_8));
   message.getBuffers().forEach(x -> newZmsg.add(x));
   newZmsg.send(socket);
  });
 }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public boolean send(ZMsg message)
{
  if (locked) {
    return false;
  }
  return message.send(pipe);
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public boolean send(ZMsg msg, boolean destroy)
{
  if (locked) {
    return false;
  }
  return msg.send(pipe, destroy);
}

代码示例来源:origin: org.opendaylight.netide/shim

public boolean send(ZMsg message, ZMQ.Socket socket) {
  if (message != null && socket != null)
    message.send(socket);
  return true;
}

代码示例来源:origin: org.zeromq/jeromq

/**
 * Send message to 0MQ socket.
 *
 * @param socket
 *              0MQ socket to send ZMsg on.
 * @return true if send is success, false otherwise
 */
public boolean send(Socket socket)
{
  return send(socket, true);
}

代码示例来源:origin: io.projectreactor/reactor-net

private void doFlush(ZMsg msg, final Subscriber<? super Void> onComplete) {
  if (null != msg) {
    boolean success = msg.send(socket);
    if (null != onComplete) {
      if (success) {
        onComplete.onComplete();
      } else {
        onComplete.onError(new RuntimeException("ZeroMQ Message could not be sent"));
      }
    }
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public String premiere(Socket pipe)
{
  ZMsg reply = new ZMsg();
  reply.add(ALIVE);
  reply.send(pipe);
  return name;
}

代码示例来源:origin: org.zeromq/jeromq

/**
   * Send a zap reply to the handler socket
   */
  private void reply(int statusCode, String statusText, Socket replies)
  {
    ZapReply reply = new ZapReply(ZAP_VERSION, sequence, statusCode, statusText, userId, metadata);
    ZMsg msg = reply.msg();
    boolean destroy = replies == null;
    msg.send(handler, destroy);
    if (replies != null) {
      // let's add other fields for convenience of listener
      msg.add(address);
      msg.add(identity);
      msg.send(replies);
    }
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
  public boolean destroyed(ZContext ctx, Socket pipe, ZPoller poller)
  {
    if (capture != null) {
      ctx.destroySocket(capture);
    }
    state.alive = false;
    if (!state.restart) {
      status().send(pipe);
    }
    return state.restart;
  }
}

代码示例来源:origin: org.projectreactor/reactor-net

private void doFlush(final Deferred<Void, Promise<Void>> onComplete) {
  ZMsg msg = MSG_UPD.get(ZeroMQNetChannel.this);
  MSG_UPD.compareAndSet(ZeroMQNetChannel.this, msg, null);
  if (null != msg) {
    boolean success = msg.send(socket);
    if (null != onComplete) {
      if (success) {
        onComplete.accept((Void) null);
      } else {
        onComplete.accept(new RuntimeException("ZeroMQ Message could not be sent"));
      }
    }
  }
}

代码示例来源:origin: net.unit8.enkan/enkan-repl-pseudo

@Override
public void run() {
  while(!Thread.currentThread().isInterrupted()) {
    ZMsg msg = ZMsg.recvMsg(socket);
    ZFrame clientAddress = msg.pop();
    String input = msg.popString();
    int cursor = Integer.parseInt(msg.popString());
    int[] anchor = {-1};
    ZMsg reply = new ZMsg();
    reply.add(clientAddress.duplicate());
    String trimmedCommand = input.trim();
    if (trimmedCommand.startsWith("/")) {
      if (!trimmedCommand.contains(" ")) {
        Predicate<String> filter = trimmedCommand.equals("/") ?
            n -> true : n -> n.startsWith(trimmedCommand.substring(1));
        commandNames.stream()
            .filter(filter)
            .forEach(s -> reply.add("/" + s));
        anchor[0] = 0;
      }
    }
    reply.send(socket, true);
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
  public boolean flow(Plug splug, Socket source, Socket capture, Plug dplug, Socket destination)
  {
    boolean success;
    // we read the whole message
    ZMsg msg = ZMsg.recvMsg(source);
    if (msg == null) {
      return false;
    }
    if (capture != null) {
      //  Copy transformed message to capture socket if any message
      // TODO what if the transformer modifies or destroys the original message ?
      ZMsg cpt = transformer.transform(msg, splug, Plug.CAPTURE);
      //                boolean destroy = !msg.equals(cpt); // TODO ?? which one
      boolean destroy = msg != cpt;
      success = cpt.send(capture, destroy);
      if (!success) {
        // not successful, but we can still try to send it to the destination
      }
    }
    ZMsg dst = transformer.transform(msg, splug, dplug);
    // we send the whole transformed message
    success = dst.send(destination);
    // finished
    msg.destroy();
    return success;
  }
}

代码示例来源:origin: kawasima/enkan

@Override
  public int complete(String buffer, int cursor, List<CharSequence> candidates) {
    @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
    ZMsg msg = new ZMsg();
    msg.add(buffer);
    msg.add(Integer.toString(cursor));
    msg.send(socket);

    ZMsg response = ZMsg.recvMsg(socket);
    while (response != null && !response.isEmpty()) {
      candidates.add(response.popString());
    }
    if (candidates.isEmpty()) return cursor;

    int delimiterPos = Math.max(buffer.lastIndexOf(' '), buffer.lastIndexOf('.'));
    if (delimiterPos > 0) {
      return delimiterPos + 1;
    } else {
      return 0;
    }
  }
}

代码示例来源:origin: fiber-space/jupyter-kernel-jsr223

public void send() {  
  msg.header.msg_id = UUID.newID();
  JSONObject jsonMsg = msg.toJSON();        
  ZMsg newZmsg = new ZMsg();
  newZmsg.add(uuid);
  newZmsg.add(bDelimiter);
  byte[] header  = jsonMsg.getJSONObject("header").toString().getBytes();
  byte[] parent  = jsonMsg.getJSONObject("parent_header").toString().getBytes();        
  byte[] meta    = jsonMsg.getJSONObject("metadata").toString().getBytes();
  byte[] content = jsonMsg.getJSONObject("content").toString().getBytes();
  byte[] digest  = computeSignature(header, parent, meta, content);
  digest = HexBinaryConverter.toHexBinary(digest).toLowerCase().getBytes();
  newZmsg.add(digest);
  newZmsg.add(header);
  newZmsg.add(parent);
  newZmsg.add(meta);
  newZmsg.add(content);        
  newZmsg.send(socket);                
}

代码示例来源:origin: kawasima/enkan

@Override
public void run() {
  while(!Thread.currentThread().isInterrupted()) {
    ZMsg msg = ZMsg.recvMsg(socket);
    ZFrame clientAddress = msg.pop();
    String input = msg.popString();
    int cursor = Integer.parseInt(msg.popString());
    int[] anchor = {-1};
    ZMsg reply = new ZMsg();
    reply.add(clientAddress.duplicate());
    String trimmedCommand = input.trim();
    if (trimmedCommand.startsWith("/")) {
      if (!trimmedCommand.contains(" ")) {
        Predicate<String> filter = trimmedCommand.equals("/") ?
            n -> true : n -> n.startsWith(trimmedCommand.substring(1));
        commandNames.stream()
            .filter(filter)
            .forEach(s -> reply.add("/" + s));
        anchor[0] = 0;
      }
    }
    reply.send(socket, true);
  }
}

代码示例来源:origin: net.unit8.enkan/enkan-repl-jshell

reply.send(socket, true);

代码示例来源:origin: org.zeromq/jeromq

return status().send(pipe);
return status().send(pipe);
return status().send(pipe);
return status().send(pipe);

代码示例来源:origin: kawasima/enkan

@Override
public void send(ReplResponse response) {
  @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
  ZMsg msg = new ZMsg();
  msg.add(clientAddress.duplicate());
  msg.add(fressian.write(response));
  msg.send(socket, true);
}

代码示例来源:origin: org.zeromq/jeromq

@Override
public boolean stage(Socket socket, Socket pipe, ZPoller poller, int evts)
{
  final ZMQ.Event event = ZMQ.Event.recv(socket);
  assert (event != null);
  final int code = event.getEvent();
  final String address = event.getAddress();
  assert (address != null);
  final Event type = Event.find(code);
  assert (type != null);
  final ZMsg msg = new ZMsg();
  msg.add(type.name());
  msg.add(Integer.toString(code));
  msg.add(address);
  final Object value = event.getValue();
  if (value != null) {
    msg.add(value.toString());
  }
  return msg.send(pipe, true);
}

代码示例来源:origin: org.opendaylight.netide/shim

break;
} else {
  message.send(socket);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com