feat: protocol multiplexing support for OCPP 1.6 and 2.0.1#419
Draft
andig wants to merge 2 commits intolorenzodonini:masterfrom
Draft
feat: protocol multiplexing support for OCPP 1.6 and 2.0.1#419andig wants to merge 2 commits intolorenzodonini:masterfrom
andig wants to merge 2 commits intolorenzodonini:masterfrom
Conversation
andig
commented
Apr 17, 2026
andig
commented
Apr 17, 2026
andig
commented
Apr 17, 2026
d48673c to
cbe5154
Compare
Enable running both OCPP 1.6 and OCPP 2.0.1 servers on a single WebSocket port using subprotocol-based message routing. Changes: - ws.Server: Add SetMessageHandlerForSubprotocol for per-subprotocol routing - ws.Server: Make Start() idempotent for shared server instances - ocppj.Server: Add SetSubprotocol to register protocol-specific handlers - ocpp1.6/ocpp2.0.1: Auto-set subprotocol in constructors - New multiplex package with MultiProtocolServer for unified API Fixes lorenzodonini#417 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…register Instead of hardcoding both OCPP 1.6 and 2.0.1 servers, the multiplex package now provides a shared WebSocket server that users can use to create their own OCPP servers. This gives full flexibility over which protocols to support. Before: server := multiplex.NewMultiProtocolServer() server.OCPP16Server().SetCoreHandler(...) After: mux := multiplex.NewServer() cs := ocpp16.NewCentralSystem(nil, mux.WebSocketServer()) cs.SetCoreHandler(...) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cbe5154 to
f1d5f94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ws.Servermultiplexpackage withMultiProtocolServerfor unified APIws.Server.Start()idempotent for shared server instancesChanges
ws package:
SetMessageHandlerForSubprotocol()- register handlers per WebSocket subprotocolSetSubprotocolSelector()- custom subprotocol negotiation callbackStart()to allow multiple OCPP servers sharing one ws.Serverocppj package:
SetSubprotocol()- configure which subprotocol the server handlesocpp1.6 / ocpp2.0.1:
multiplex package (new):
MultiProtocolServerinterface and implementationexample/multiplex/Test plan
make test)TestSubprotocolSelectorandTestSubprotocolSelectorDefaultBehaviortestsFixes #417, depends on #230
🤖 Generated with Claude Code