feat(ocpp): 添加对WebSocket子协议的支持和缺失参数检查

This commit is contained in:
2026-03-15 03:41:38 +08:00
parent b45896a9dd
commit 216a8e118d
3 changed files with 34 additions and 5 deletions

View File

@@ -85,8 +85,12 @@ app.get(
'/ocpp/:chargePointId',
upgradeWebSocket((c) => {
const chargePointId = c.req.param('chargePointId')
if (!chargePointId) {
throw new Error('Missing chargePointId route param')
}
const connInfo = getConnInfo(c)
return createOcppHandler(chargePointId, connInfo.remote.address)
const requestedProtocol = c.req.header('sec-websocket-protocol')
return createOcppHandler(chargePointId, connInfo.remote.address, requestedProtocol)
}),
)