当前位置: 首页>>代码示例>>Java>>正文


Java ZFrame.getData方法代码示例

本文整理汇总了Java中org.zeromq.ZFrame.getData方法的典型用法代码示例。如果您正苦于以下问题:Java ZFrame.getData方法的具体用法?Java ZFrame.getData怎么用?Java ZFrame.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.zeromq.ZFrame的用法示例。


在下文中一共展示了ZFrame.getData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gunzipMultifameZMsg

import org.zeromq.ZFrame; //导入方法依赖的package包/类
public static String[] gunzipMultifameZMsg(ZMsg msg) throws IOException {
	Iterator<ZFrame> frames = msg.iterator();
	// pop off first frame, which contains "/GOVI/KV8" (the feed name)
	// (isn't there a method for this?)
	String header = frames.next().toString();
	ByteArrayOutputStream buffer = new ByteArrayOutputStream();
	while (frames.hasNext()) {
		ZFrame frame = frames.next();
		byte[] frameData = frame.getData();
		buffer.write(frameData);
	}
	if (buffer.size() == 0) {
		return null;
	}
	// chain input streams to gunzip contents of byte buffer
	InputStream gzippedMessageStream = new ByteArrayInputStream(
			buffer.toByteArray());
	InputStream messageStream = new GZIPInputStream(gzippedMessageStream);
	// copy input stream back to transport stream
	buffer.reset();
	byte[] b = new byte[4096];
	for (int n; (n = messageStream.read(b)) != -1;) {
		buffer.write(b, 0, n);
	}
	return new String[] { header, buffer.toString() };
}
 
开发者ID:CROW-NDOV,项目名称:displaydirect,代码行数:27,代码来源:ZeroMQUtils.java

示例2: verifyDelim

import org.zeromq.ZFrame; //导入方法依赖的package包/类
private String verifyDelim(ZFrame zframe) {
  String delim = new String(zframe.getData(), StandardCharsets.UTF_8);
  if (!DELIM.equals(delim)) {
    throw new RuntimeException("Delimiter <IDS|MSG> not found");
  }
  return delim;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:8,代码来源:KernelSocketsZMQ.java

示例3: TransferWrapperRaw

import org.zeromq.ZFrame; //导入方法依赖的package包/类
/**
 * Expect multipart message at least three parts:
 *
 * 0       envelope frame         -> envelope[N-4]
 * ...
 * N-4     envelope frame         -> envelope[0]
 * N-3     Empty Delimiter Frame
 * N-2     Serialized callback ID -> callbackId
 * N-1     Serialized payload     -> payload
 *
 * @param message input
 * @throws TransferHelper.ProtocolException if protocol is violated
 */
public TransferWrapperRaw(ZMsg message) throws TransferHelper.ProtocolException {
    if (message == null) { throw new IllegalArgumentException(); }
    int N = message.size();

    if (N <= 2) {
        throw new TransferHelper.ProtocolException("Wrong number of Frames. Expected lower than 3: " + message.size());
    }

    ZFrame payloadFrame = message.pollLast();
    ZFrame callbackFrame = message.pollLast();
    ZFrame delimiterFrame = message.pollLast();

    if (delimiterFrame.size() != 0) {
        throw new TransferHelper.ProtocolException("Delimiter frame not empty.");
    }

    callbackId = TransferHelper.bytes2int(callbackFrame.getData());

    payload = payloadFrame.getData();

    envelope = new ZFrame[N-3];
    for(int i = 0; i < N-3; i++) {
        envelope[i] = message.pollLast();
    }

    if (message.size() != 0) throw new IllegalStateException("Message not empty.");
}
 
开发者ID:HeinrichHartmann,项目名称:RequestDispatcher,代码行数:41,代码来源:TransferWrapperRaw.java

示例4: Worker

import org.zeromq.ZFrame; //导入方法依赖的package包/类
protected Worker(ZFrame address) {
    this.address = address;
    identity = new String(address.getData(), ZMQ.CHARSET);
    expiry = System.currentTimeMillis() + HEARTBEAT_INTERVAL * HEARTBEAT_LIVENESS;
}
 
开发者ID:zeromq,项目名称:jeromq3-x,代码行数:6,代码来源:ppqueue.java


注:本文中的org.zeromq.ZFrame.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。