parseSwampSubprotocol function
- String subprotocol
Parses a WebSocket subprotocol string (e.g. swamp-1) and returns
the protocol version number, or null if the format is invalid.
Implementation
int? parseSwampSubprotocol(String subprotocol) {
if (!subprotocol.startsWith(kSwampProtocolPrefix)) return null;
return int.tryParse(subprotocol.substring(kSwampProtocolPrefix.length));
}