use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method sendCommandToAllSessions.
protected ServiceResponsesList sendCommandToAllSessions(CommandScript script, WebSocketServiceResponse response) {
logger.debug("About to send command {} to kie server located at {}", script, url);
List<Session> sessions = manager.getByUrl(url);
List<ServiceResponse<?>> responses = new ArrayList<>();
ServiceResponsesList result = new ServiceResponsesList(responses);
for (Session session : sessions) {
logger.debug("Web Socket session ({}) is open {}", session.getId(), session.isOpen());
String content = WebSocketUtils.marshal(script);
logger.debug("Content to be sent over Web Socket '{}'", content);
try {
manager.getHandler(session.getId()).addHandler(response);
session.getBasicRemote().sendText(content);
logger.debug("Message successfully sent to kie server");
responses.add(response);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method getServerState.
@Override
public ServiceResponse<KieServerStateInfo> getServerState() {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new GetServerStateCommand()));
ServiceResponse<KieServerStateInfo> response = (ServiceResponse<KieServerStateInfo>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method getReleaseId.
@Override
public ServiceResponse<ReleaseId> getReleaseId(String containerId) {
CommandScript script = new CommandScript(Collections.singletonList(new GetReleaseIdCommand(containerId)));
ServiceResponse<ReleaseId> response = (ServiceResponse<ReleaseId>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method updateReleaseId.
@Override
public ServiceResponse<ReleaseId> updateReleaseId(String id, ReleaseId releaseId, boolean resetBeforeUpdate) {
CommandScript script = new CommandScript(Collections.singletonList(new UpdateReleaseIdCommand(id, releaseId, resetBeforeUpdate)));
ServiceResponse<ReleaseId> response = (ServiceResponse<ReleaseId>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> {
ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
return list.getResponses().get(0);
})).getResponses().get(0);
return response;
}
use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.
the class WebSocketKieServerClient method sendCommand.
protected ServiceResponsesList sendCommand(CommandScript script, WebSocketServiceResponse response) {
logger.debug("About to send command {} to kie server located at {}", script, url);
List<Session> sessions = manager.getByUrl(url);
Session session = sessions.get(0);
logger.debug("Web Socket session ({}) is open {}", session.getId(), session.isOpen());
String content = WebSocketUtils.marshal(script);
logger.debug("Content to be sent over Web Socket '{}'", content);
try {
manager.getHandler(session.getId()).addHandler(response);
session.getBasicRemote().sendText(content);
logger.debug("Message successfully sent to kie server");
return new ServiceResponsesList(Arrays.asList(response));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations