Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2010 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/658942 to your computer and use it in GitHub Desktop.
Save anonymous/658942 to your computer and use it in GitHub Desktop.
# The class to parse all of the BNCS packets
class BncsHandler
def initialize(client, packet)
@client, @packet, @unpacked = client, packet, packet.unpack("C*")
end
def handle
command = @unpacked[1]
log "S->C packet 0x#{"%02X" % command}"
log @packet.hexdump
case command
when 0x25 then pong(@packet)
when 0x50 then check_revision(@packet)
end
end
protected
def log(text)
puts "#{text}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment