gpt4 book ai didi

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

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

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

ZMsg.size介绍

暂无

代码示例

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

private Message readMessage(ZMQ.Socket socket) {
 ZMsg zmsg = null;
 Message message = null;
 try {
  zmsg = ZMsg.recvMsg(socket);
  ZFrame[] parts = new ZFrame[zmsg.size()];
  zmsg.toArray(parts);
  byte[] uuid = parts[MessageParts.UUID].getData();
  byte[] header = parts[MessageParts.HEADER].getData();
  byte[] parent = parts[MessageParts.PARENT].getData();
  byte[] metadata = parts[MessageParts.METADATA].getData();
  byte[] content = parts[MessageParts.CONTENT].getData();
  byte[] expectedSig = parts[MessageParts.HMAC].getData();
  verifyDelim(parts[MessageParts.DELIM]);
  verifySignatures(expectedSig, header, parent, metadata, content);
  message = new Message(parse(header, Header.class));
  if (uuid != null) {
   message.getIdentities().add(uuid);
  }
  message.setParentHeader(parse(parent, Header.class));
  message.setMetadata(parse(metadata, LinkedHashMap.class));
  message.setContent(parse(content, LinkedHashMap.class));
 } finally {
  if (zmsg != null) {
   zmsg.destroy();
  }
 }
 return message;
}

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

@Override
  public int handle(ZLoop loop, ZMQ.PollItem item, Object arg) {
    ZMsg msg = ZMsg.recvMsg(socket);
    if (null == msg || msg.size() == 0) {
      return 0;
    }
    if (closed) {
      return -1;
    }
    b.onNext(msg);
    return 0;
  }
};

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

file.writeInt(msg.size());
if (msg.size() > 0) {
  for (ZFrame f : msg) {

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

@Override
public boolean configure(ZMsg msg, boolean verbose)
{
  assert (msg.size() == 2);
  // For now we don't do anything with domains
  @SuppressWarnings("unused")
  String domain = msg.popString();
  // Get password file and load into HashMap
  // If the file doesn't exist we'll get an empty map
  String filename = msg.popString();
  passwordsFile = new File(filename);
  if (verbose) {
    System.out.printf(
             "ZAuth: activated plain-mechanism with password-file: %s%n",
             passwordsFile.getAbsolutePath());
  }
  try {
    loadPasswords(true);
  }
  catch (IOException e) {
    // Ignore the exception, just don't read the file
  }
  return true;
}

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

private ZEvent(ZMsg msg)
{
  assert (msg != null);
  assert (msg.size() == 3 || msg.size() == 4);
  type = Event.valueOf(msg.popString());
  code = Integer.valueOf(msg.popString());
  address = msg.popString();
  if (msg.isEmpty()) {
    value = null;
  }
  else {
    value = msg.popString();
  }
}

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

public void read() {
  try {
    ZFrame[] zframes = new ZFrame[zmsg.size()];
    zmsg.toArray(zframes);
    if (zmsg.size() < 7) {
      throw new RuntimeException("[jupyter-kernel.jar] Message incomplete. Didn't receive required message parts");

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

@Override
public ZMsg recv(boolean wait)
{
  if (locked) {
    return null;
  }
  try {
    ZMsg msg = ZMsg.recvMsg(pipe, wait);
    if (msg == null) {
      return null;
    }
    if (msg.size() == 1) {
      final ZFrame frame = msg.peek();
      byte[] key = frame.getData();
      if (lock != null && Arrays.equals(lock, key)) {
        locked = true;
        // this is the last message anyway, and not a one for a public display
        msg = null;
        pipe.close();
      }
    }
    return msg;
  }
  catch (ZMQException e) {
    locked = true;
    return null;
  }
}

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

/**
 * Pop frame off front of message, caller now owns frame.
 * If next frame is empty, pops and destroys that empty frame
 * (e.g. useful when unwrapping ROUTER socket envelopes)
 * @return
 *          Unwrapped frame
 */
public ZFrame unwrap()
{
  if (size() == 0) {
    return null;
  }
  ZFrame f = pop();
  ZFrame empty = getFirst();
  if (empty.hasData() && empty.size() == 0) {
    empty = pop();
    empty.destroy();
  }
  return f;
}

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

private static ZapReply received(ZMsg msg)
  {
    if (msg == null) {
      return null;
    }
    assert (msg.size() == 8);
    String version = msg.popString();
    String sequence = msg.popString();
    int statusCode = Integer.parseInt(msg.popString());
    String statusText = msg.popString();
    String userId = msg.popString();
    ZMetadata metadata = ZMetadata.read(msg.popString());
    String address = msg.popString();
    String identity = msg.popString();
    return new ZapReply(version, sequence, statusCode, statusText, userId, metadata, address, identity);
  }
}

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

@Override
  public int handle(ZLoop loop, ZMQ.PollItem item, Object arg) {
    ZMsg msg = ZMsg.recvMsg(socket);
    if (null == msg || msg.size() == 0) {
      return 0;
    }
    if (closed) {
      return -1;
    }
    String connId;
    switch (ZeroMQWorker.this.socketType) {
      case ZMQ.ROUTER:
        connId = msg.popString();
        break;
      default:
        connId = ZeroMQWorker.this.id.toString();
    }
    ZeroMQNetChannel<IN, OUT> netChannel = select(connId)
        .setConnectionId(connId)
        .setSocket(socket);
    ZFrame content;
    while (null != (content = msg.pop())) {
      netChannel.read(Buffer.wrap(content.getData()));
    }
    msg.destroy();
    return 0;
  }
};

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