Sha256: d4b9d536dae9f2594312912fe5813693d0852c42923aa11285266845b099c1db
Contents?: true
Size: 767 Bytes
Versions: 1
Compression:
Stored size: 767 Bytes
Contents
module TellaPeer class Pong < Message attr_writer :ip, :port def initialize(header = nil, body = '') super(header, body) unless body.empty? content = body.unpack(payload_packer) self.port = content.first self.ip = content[1..-1].map(&:to_i) end self.payload_length = 6 end def ip @ip = @ip.map(&:to_i) if @ip && @ip.first.kind_of?(String) @ip ||= Message.ip.map(&:to_i) end def pretty_ip ip.map(&:to_s).join('.') end def key "#{pretty_ip}:#{port}" end def port @port ||= Message.port end def payload [port] + ip end def payload_packer 'nCCCC' end def type MessageTypes::PONG end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tella_peer-0.0.1 | lib/tella_peer/pong.rb |