Module: AnyCable::Rack::Coders::Protobuf
- Defined in:
- lib/anycable/rack/coders/protobuf.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.decode(bin) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/anycable/rack/coders/protobuf.rb', line 12 def decode(bin) = ActionCable::Message.decode(bin).to_h [:command] = [:command].to_s if [:message].present? [:message] = Msgpack.decode([:message]) end .each_with_object({}) { |(k, v), h| h[k.to_s] = v } end |
.encode(ruby_obj) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/anycable/rack/coders/protobuf.rb', line 23 def encode(ruby_obj) = ruby_obj.delete(:message) data = ActionCable::Message.new(ruby_obj) if data. = Msgpack.encode(, binary_frame_wrap: false) end BinaryFrame.new(ActionCable::Message.encode(data)) end |