use of org.eclipse.milo.opcua.sdk.server.api.services.MethodServices.CallContext in project milo by eclipse.
the class DefaultMethodServiceSet method onCall.
@Override
public void onCall(ServiceRequest service) {
callCounter.record(service);
OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();
Session session = service.attr(ServiceAttributes.SESSION_KEY).get();
CallRequest request = (CallRequest) service.getRequest();
List<CallMethodRequest> methodsToCall = l(request.getMethodsToCall());
if (methodsToCall.isEmpty()) {
service.setServiceFault(StatusCodes.Bad_NothingToDo);
return;
}
if (methodsToCall.size() > server.getConfig().getLimits().getMaxNodesPerMethodCall().longValue()) {
service.setServiceFault(StatusCodes.Bad_TooManyOperations);
return;
}
DiagnosticsContext<CallMethodRequest> diagnosticsContext = new DiagnosticsContext<>();
CallContext context = new CallContext(server, session, diagnosticsContext);
server.getAddressSpaceManager().call(context, methodsToCall);
context.getFuture().thenAccept(values -> {
ResponseHeader header = service.createResponseHeader();
CallResponse response = new CallResponse(header, a(values, CallMethodResult.class), new DiagnosticInfo[0]);
service.setResponse(response);
});
}
Aggregations