Class: Syncro::Protocol::Message

Inherits:
HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/syncro/protocol/message.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fromJSON(str) ⇒ Object



6
7
8
# File 'lib/syncro/protocol/message.rb', line 6

def self.fromJSON(str)
	self.new(JSON.parse(str))
end

Instance Method Details

#serializeObject



18
19
20
21
# File 'lib/syncro/protocol/message.rb', line 18

def serialize
  data = self.to_json
  [data.length].pack('n') + data
end

#typeObject



10
11
12
# File 'lib/syncro/protocol/message.rb', line 10

def type
	self[:type].try(:to_sym)
end

#type=(sym) ⇒ Object



14
15
16
# File 'lib/syncro/protocol/message.rb', line 14

def type=(sym)
	self[:type] = sym
end