Module: Goat::JSONMessages

Defined in:
lib/goat/net-common.rb

Overview

for use with EM::Connection

Instance Method Summary collapse

Instance Method Details

#send_message(type, msg) ⇒ Object



38
39
40
# File 'lib/goat/net-common.rb', line 38

def send_message(type, msg)
  send_data(msg.merge('type' => type).to_json + "\n")
end

#send_messages(msgs) ⇒ Object



42
43
44
# File 'lib/goat/net-common.rb', line 42

def send_messages(msgs)
  send_data(msgs.map{|msg| msg[1].merge('type' => msg[0])}.to_json + "\n")
end