Class: GameOverseer::MessagePackPacketHandler

Inherits:
PacketHandler show all
Defined in:
lib/gameoverseer/packet_handler/messagepack_packet_handler.rb

Instance Method Summary collapse

Methods inherited from PacketHandler

#initialize, instance, instance=

Constructor Details

This class inherits a constructor from GameOverseer::PacketHandler

Instance Method Details

#pre_processor(packet, sending) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/gameoverseer/packet_handler/messagepack_packet_handler.rb', line 12

def pre_processor(packet, sending)
  data = nil
  if sending
    data = packet.to_msgpack
  else
    data = MessagePack.unpack(packet)
  end

  return data
end

#receive(client_id, packet) ⇒ Object



23
24
25
# File 'lib/gameoverseer/packet_handler/messagepack_packet_handler.rb', line 23

def receive(client_id, packet)
  _packet = pre_processor(packet, false)
end

#setupObject



4
5
6
7
8
9
10
# File 'lib/gameoverseer/packet_handler/messagepack_packet_handler.rb', line 4

def setup
  begin
    require "msgpack"
  rescue LoadError
    abort "msgpack is not installed."
  end
end

#transmit(client_id, data) ⇒ Object



27
28
29
# File 'lib/gameoverseer/packet_handler/messagepack_packet_handler.rb', line 27

def transmit(client_id, data)
  _packet = pre_processor(data, true)
end