parse method
Parse a raw string into a typed protocol object.
Implementation
ProtocolMessage parse(String raw) {
final json = deserialize(raw);
final type = classify(json);
return switch (type) {
MessageType.request => ProtocolMessage.request(
BridgeRequest.fromJson(json),
),
MessageType.response => ProtocolMessage.response(
BridgeResponse.fromJson(json),
),
MessageType.notification => ProtocolMessage.notification(
BridgeNotification.fromJson(json),
),
};
}