Skip to content

Commit 06565f2

Browse files
dwibudutlorenzodonini
authored andcommitted
adding missed handler on disconnected client
1 parent 9f716f9 commit 06565f2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ocpp2.0.1/csms.go

+4
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,10 @@ func (cs *csms) SetNewChargingStationHandler(handler ChargingStationConnectionHa
749749

750750
func (cs *csms) SetChargingStationDisconnectedHandler(handler ChargingStationConnectionHandler) {
751751
cs.server.SetDisconnectedClientHandler(func(chargingStation ws.Channel) {
752+
for cb, ok := cs.callbackQueue.Dequeue(chargingStation.ID()); ok; cb, ok = cs.callbackQueue.Dequeue(chargingStation.ID()) {
753+
err := ocpp.NewError(ocppj.GenericError, "client disconnected, no response received from client", "")
754+
cb(nil, err)
755+
}
752756
handler(chargingStation)
753757
})
754758
}

ocpp2.0.1/v2.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,24 @@ func NewCSMS(endpoint *ocppj.Server, server ws.WsServer) CSMS {
421421
}
422422
server.AddSupportedSubprotocol(types.V201Subprotocol)
423423
if endpoint == nil {
424-
dispatcher := ocppj.NewDefaultServerDispatcher(ocppj.NewFIFOQueueMap(0))
425-
endpoint = ocppj.NewServer(server, dispatcher, nil, authorization.Profile, availability.Profile, data.Profile, diagnostics.Profile, display.Profile, firmware.Profile, iso15118.Profile, localauth.Profile, meter.Profile, provisioning.Profile, remotecontrol.Profile, reservation.Profile, security.Profile, smartcharging.Profile, tariffcost.Profile, transactions.Profile)
424+
endpoint = ocppj.NewServer(server, nil, nil,
425+
authorization.Profile,
426+
availability.Profile,
427+
data.Profile,
428+
diagnostics.Profile,
429+
display.Profile,
430+
firmware.Profile,
431+
iso15118.Profile,
432+
localauth.Profile,
433+
meter.Profile,
434+
provisioning.Profile,
435+
remotecontrol.Profile,
436+
reservation.Profile,
437+
security.Profile,
438+
smartcharging.Profile,
439+
tariffcost.Profile,
440+
transactions.Profile,
441+
)
426442
}
427443
cs := newCSMS(endpoint)
428444
cs.server.SetRequestHandler(func(client ws.Channel, request ocpp.Request, requestId string, action string) {

0 commit comments

Comments
 (0)