-
Notifications
You must be signed in to change notification settings - Fork 696
Description
In our app we have a custom websocket connection that is shared by many clients. This one connection is multiplexed out via a top level key in the json payload. For this we need to manually parse and inspect the json payload.
Apollo has a private parseServerMessage(text:String) API which handles much of the parsing of the raw payload into a json object and further websocket specific logic.
To avoid us needing to parse the payload, and then apollo needing to parse it again, we currently fork parseServerMessage and add some extra logic after parsing but before websocket-specific inspection.
Ideally it would be nice to re-use apollo's logic while avoiding the double parsing so the proposal is to expose a public fun parseServerMessage(Map<String, Any?>).
This way the private parseServerMessage(text:String) becomes:
private parseServerMessage(text:String): ... {
val parsedJsonData: Map<String, Any?> = ...;
return parseServerMessage(parsedJsonData)
}while in our case we can reuse most of the logic with:
private parseServerMessage(text:String): ... {
val parsedJsonData: Map<String, Any?> = ...;
if (parsedJsonData["routingKey"] != "apollo-ws") return null
return parseServerMessage(parsedJsonData)
}