use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.
the class AbstractChargePointServiceInvoker method run.
/**
* Actual processing
*/
private void run(String chargeBoxId, CommunicationTask task) {
RequestType request = task.getRequest();
String messageId = UUID.randomUUID().toString();
ActionResponsePair pair = typeStore.findActionResponse(request);
if (pair == null) {
throw new SteveException("Action name is not found");
}
OcppJsonCall call = new OcppJsonCall();
call.setMessageId(messageId);
call.setPayload(request);
call.setAction(pair.getAction());
FutureResponseContext frc = new FutureResponseContext(task, pair.getResponseClass());
CommunicationContext context = new CommunicationContext(endpoint.getSession(chargeBoxId), chargeBoxId);
context.setOutgoingMessage(call);
context.setFutureResponseContext(frc);
outgoingCallPipeline.accept(context);
}
use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.
the class OcppJsonChargePoint method prepare.
public <T extends ResponseType> void prepare(RequestType request, Class<T> responseClass, Consumer<T> responseHandler, Consumer<OcppJsonError> errorHandler) {
String messageId = UUID.randomUUID().toString();
OcppJsonCall call = new OcppJsonCall();
call.setMessageId(messageId);
call.setPayload(request);
call.setAction(getOperationName(request));
// session is null, because we do not need org.springframework.web.socket.WebSocketSession
CommunicationContext ctx = new CommunicationContext(null, chargeBoxId);
ctx.setOutgoingMessage(call);
Serializer.INSTANCE.accept(ctx);
ResponseContext resCtx = new ResponseContext(ctx.getOutgoingString(), responseClass, responseHandler, errorHandler);
responseContextMap.put(messageId, resCtx);
}
use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.
the class AbstractWebSocketEndpoint method handleTextMessage.
private void handleTextMessage(WebSocketSession session, TextMessage webSocketMessage) throws Exception {
String incomingString = webSocketMessage.getPayload();
String chargeBoxId = getChargeBoxId(session);
log.info("[chargeBoxId={}, sessionId={}] Received message: {}", chargeBoxId, session.getId(), incomingString);
CommunicationContext context = new CommunicationContext(session, chargeBoxId);
context.setIncomingString(incomingString);
pipeline.accept(context);
}
Aggregations