use of zmq.Msg in project jeromq by zeromq.
the class RawDecoder method decode.
@Override
public Step.Result decode(ByteBuffer buffer, int size, ValueReference<Integer> processed) {
processed.set(size);
inProgress = new Msg(size);
inProgress.put(buffer);
return Step.Result.DECODED;
}
use of zmq.Msg in project jeromq by zeromq.
the class ZSocket method sendFrame.
/**
* Send a frame
*
* @param frame
* @param flags
* @return return true if successful
*/
public boolean sendFrame(ZFrame frame, int flags) {
final byte[] data = frame.getData();
final Msg msg = new Msg(data);
if (socketBase.send(msg, flags)) {
return true;
}
mayRaise();
return false;
}
use of zmq.Msg in project jeromq by zeromq.
the class ZSocket method send.
public int send(byte[] b, int flags) {
final Msg msg = new Msg(b);
if (socketBase.send(msg, flags)) {
return msg.size();
}
mayRaise();
return -1;
}
use of zmq.Msg in project jeromq by zeromq.
the class SessionBase method pullMsg.
protected Msg pullMsg() {
if (pipe == null) {
return null;
}
Msg msg = pipe.read();
if (msg == null) {
return null;
}
incompleteIn = msg.hasMore();
return msg;
}
use of zmq.Msg in project jeromq by zeromq.
the class SessionBase method zapConnect.
public int zapConnect() {
assert (zapPipe == null);
Ctx.Endpoint peer = findEndpoint("inproc://zeromq.zap.01");
if (peer.socket == null) {
errno.set(ZError.ECONNREFUSED);
return ZError.ECONNREFUSED;
}
if (peer.options.type != ZMQ.ZMQ_REP && peer.options.type != ZMQ.ZMQ_ROUTER && peer.options.type != ZMQ.ZMQ_SERVER) {
errno.set(ZError.ECONNREFUSED);
return ZError.ECONNREFUSED;
}
// Create a bi-directional pipe that will connect
// session with zap socket.
ZObject[] parents = { this, peer.socket };
int[] hwms = { 0, 0 };
boolean[] conflates = { false, false };
Pipe[] pipes = Pipe.pair(parents, hwms, conflates);
// Attach local end of the pipe to this socket object.
zapPipe = pipes[0];
zapPipe.setNoDelay();
zapPipe.setEventSink(this);
sendBind(peer.socket, pipes[1], false);
// Send empty identity if required by the peer.
if (peer.options.recvIdentity) {
Msg id = new Msg();
id.setFlags(Msg.IDENTITY);
zapPipe.write(id);
zapPipe.flush();
}
return 0;
}
Aggregations