Class: GameOverseer::JsonPacketHandler
Instance Method Summary
collapse
#initialize, instance, instance=
Instance Method Details
#pre_processor(packet, sending) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/gameoverseer/packet_handler/json_packet_handler.rb', line 15
def pre_processor(packet, sending)
data = nil
if sending
data = MultiJson.dump(packet)
else
data = MultiJson.load(packet)
end
return data
end
|
#receive(client_id, packet) ⇒ Object
26
27
28
|
# File 'lib/gameoverseer/packet_handler/json_packet_handler.rb', line 26
def receive(client_id, packet)
_packet = pre_processor(packet, false)
end
|
#setup ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/gameoverseer/packet_handler/json_packet_handler.rb', line 4
def setup
begin
require "multi_json"
if defined?(Oj)
Oj.default_options={mode: :strict}
end
rescue LoadError
abort "MultiJson is not installed."
end
end
|
#transmit(client_id, data) ⇒ Object
30
31
32
|
# File 'lib/gameoverseer/packet_handler/json_packet_handler.rb', line 30
def transmit(client_id, data)
_packet = pre_processor(data, true)
end
|