use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class Comm method messageMessage.
public static Message messageMessage(JupyterMessages type, Buffer buffer, Map<String, Serializable> content, Message parentMessage) {
Message message = new Message();
message.setHeader(new Header(type, parentMessage != null ? parentMessage.getHeader().getSession() : null));
if (parentMessage != null) {
message.setParentHeader(parentMessage.getHeader());
}
message.setContent(content);
message.setMetadata(buildMetadata());
if (!buffer.isEmpty()) {
message.setBuffers(buffer.getBuffers());
}
return message;
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class Comm method sendUpdate.
public void sendUpdate(final String propertyName, final Object value) {
Message message = createUpdateMessage(propertyName, value);
kernel.publish(singletonList(message));
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class Comm method close.
public void close() {
Message parentMessage = getParentMessage();
if (this.getCloseCallbackList() != null && !this.getCloseCallbackList().isEmpty()) {
for (Handler<Message> handler : getCloseCallbackList()) {
handler.handle(parentMessage);
}
}
Message message = new Message();
message.setHeader(new Header(COMM_CLOSE, parentMessage != null ? parentMessage.getHeader().getSession() : null));
if (parentMessage != null) {
message.setParentHeader(parentMessage.getHeader());
}
HashMap<String, Serializable> map = new HashMap<>();
map.put(COMM_ID, getCommId());
map.put(DATA, new HashMap<>());
map.put(METADATA, new HashMap<>());
message.setContent(map);
message.setMetadata(buildMetadata());
kernel.removeComm(getCommId());
kernel.publish(singletonList(message));
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class CommCloseHandler method handleMsg.
private void handleMsg(Message message) {
logger.debug("Processing CommCloseHandler");
Map<String, Serializable> commMap = message.getContent();
String targetName = (kernel.getComm(getString(commMap, COMM_ID)) != null) ? kernel.getComm(getString(commMap, COMM_ID)).getTargetName() : "";
kernel.removeComm(getString(commMap, COMM_ID));
Message reply = new Message();
reply.setHeader(new Header(COMM_CLOSE, message.getHeader().getSession()));
HashMap<String, Serializable> map = new HashMap<>();
map.put(DATA, new HashMap<>());
reply.setContent(map);
reply.setParentHeader(message.getHeader());
reply.setIdentities(message.getIdentities());
send(reply);
logger.debug("Comm closed, target name = " + targetName);
}
use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.
the class ExecuteRequestHandler method announceTheCode.
private void announceTheCode(Message message, String code) {
Message reply = new Message();
reply.setParentHeader(message.getHeader());
reply.setIdentities(message.getIdentities());
reply.setHeader(new Header(EXECUTE_INPUT, message.getHeader().getSession()));
Map<String, Serializable> map1 = new HashMap<>(2);
map1.put("execution_count", executionCount);
map1.put("code", code);
reply.setContent(map1);
kernel.publish(singletonList(reply));
}
Aggregations