Search in sources :

Example 1 with OcppJsonResponse

use of de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResponse in project steve by RWTH-i5-IDSG.

the class OcppJsonChargePoint method onMessage.

@OnWebSocketMessage
public void onMessage(Session session, String msg) {
    try {
        OcppJsonResponse response = deserializer.extractResponse(msg);
        ResponseContext ctx = responseContextMap.remove(response.getMessageId());
        if (response instanceof OcppJsonResult) {
            ctx.responseHandler.accept(((OcppJsonResult) response).getPayload());
        } else if (response instanceof OcppJsonError) {
            ctx.errorHandler.accept((OcppJsonError) response);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (receivedResponsesSignal != null) {
            receivedResponsesSignal.countDown();
        }
    }
}
Also used : OcppJsonResponse(de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResponse) OcppJsonResult(de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResult) OcppJsonError(de.rwth.idsg.steve.ocpp.ws.data.OcppJsonError) IOException(java.io.IOException) OnWebSocketMessage(org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)

Aggregations

OcppJsonError (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonError)1 OcppJsonResponse (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResponse)1 OcppJsonResult (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonResult)1 IOException (java.io.IOException)1 OnWebSocketMessage (org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage)1