org.zeromq.ZFrame.duplicate()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(101)

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

ZFrame.duplicate介绍

[英]Creates a new frame that duplicates an existing frame
[中]创建与现有帧重复的新帧

代码示例

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

/**
 * Creates copy of this ZMsg.
 * Also duplicates all frame content.
 * @return
 *          The duplicated ZMsg object, else null if this ZMsg contains an empty frame set
 */
public ZMsg duplicate()
{
  if (frames.isEmpty()) {
    return null;
  }
  else {
    ZMsg msg = new ZMsg();
    for (ZFrame f : frames) {
      msg.add(f.duplicate());
    }
    return msg;
  }
}

代码示例来源: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: 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.add(clientAddress.duplicate());

代码示例来源: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);
}

相关文章