protocol
devtools protocol version 1.3 for Crystal
Converted from official ChromeDevTools repo json files
Installation
-
Add the dependency to your
shard.yml
:dependencies: protocol: github: dammer/protocol
-
Run
shards install
Usage
require "protocol"
def process_message(raw : String)
m = NamedTuple(id: UInt64?, method: String?).from_json(raw)
if cmd_id = m[:id]
emit CommandEvent, cmd_id, raw
else
event = map_events(m) # Protocol::EVENTS_MAP[name]
{% begin %}
case event
{% for _, event in Protocol::EVENTS_MAP %}
when {{ event }}.class
emit {{event}}, Protocol::{{event}}.from_json(raw, root: "params")
{% end %}
end
{% end %}
end
end
Contributing
- Fork it (https://github.com/dammer/protocol/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Damir Sharipov - creator and maintainer
Repository
protocol
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- almost 2 years ago
- November 13, 2022
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 16:33:56 GMT
Languages