Module: Mycel::Channel::Message

Defined in:
lib/mycel.rb

Overview

Wire-message constructors. String keys are used throughout so the same Hash shape survives encode → bytes → decode without symbol/ string drift (JSON.parse always yields String keys).

Class Method Summary collapse

Class Method Details

.generate_msg(type, id) ⇒ Object



361
362
363
# File 'lib/mycel.rb', line 361

def self.generate_msg(type, id)
  { 'v' => PROTOCOL_VERSION, 'type' => type, 'id' => id }
end

.generate_payload_msg(type, id, payload) ⇒ Object



365
366
367
# File 'lib/mycel.rb', line 365

def self.generate_payload_msg(type, id, payload)
  { 'v' => PROTOCOL_VERSION, 'type' => type, 'id' => id, 'payload' => payload }
end