-
Notifications
You must be signed in to change notification settings - Fork 176
Setting up v1.6 OCPP S server
Thomas Volden edited this page May 8, 2017
·
1 revision
For version 1.6 OCPP-S (SOAP) server.
// The core profile is mandatory
core = new ServerCoreProfile(new ServerCoreEventHandler() {
@Override
public AuthorizeConfirmation handleAuthorizeRequest(UUID sessionIndex, AuthorizeRequest request) {
System.out.println(request);
// ... handle event
return new AuthorizeConfirmation();
}
@Override
public BootNotificationConfirmation handleBootNotificationRequest(UUID sessionIndex, BootNotificationRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public DataTransferConfirmation handleDataTransferRequest(UUID sessionIndex, DataTransferRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public HeartbeatConfirmation handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public MeterValuesConfirmation handleMeterValuesRequest(UUID sessionIndex, MeterValuesRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public StartTransactionConfirmation handleStartTransactionRequest(UUID sessionIndex, StartTransactionRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public StatusNotificationConfirmation handleStatusNotificationRequest(UUID sessionIndex, StatusNotificationRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
@Override
public StopTransactionConfirmation handleStopTransactionRequest(UUID sessionIndex, StopTransactionRequest request) {
System.out.println(request);
// ... handle event
return null; // returning null means unsupported feature
}
});
server = new SOAPServer(core);
server.open("localhost", 8887, new ServerEvents() {
@Override
public void newSession(UUID sessionIndex, String identifier) {
// sessionIndex is used to send messages.
System.out.println("New session " + sessionIndex + ": " + identifier);
}
@Override
public void lostSession(UUID sessionIndex) {
System.out.println("Session " + sessionIndex + " lost connection");
}
});
// Use the feature profile to help create event
ClearCacheRequest request = core.createClearCacheRequest();
UUID sessionIndex = null;
// Server returns a promise which will be filled once it receives a confirmation.
// Select the distination client with the sessionIndex integer.
server.send(sessionIndex, request).whenComplete((confirmation, throwable) -> System.out.println(confirmation));