I invite you to give a look at the Chrome DevTools protocol
It is a JSON-RPC protocol working on Websockets allowing to perform remote debugging processes based on the V8 JavaScript engine (and for Node.js and all Blink based Browsers)
You can find a lot of libraries (client & server libraries) in many languages (JavaScript, TypeScript, PHP, Python, Ruby, Go, Rust, Java, Kotlin, Closure, C#, Objective C) built over that protocol:
It does have the notion of subscription over dedicated api-level methods like
- Network.enable: Enables network tracking, network events will be delivered to the client.
- Network.disable: Disables network tracking, prevents network events from being sent to the client.
Note:
- It is more using a JSON-RPC v1 without batch but you're free to use the v2 for your own protocol