Class: CresIP::Echo

Inherits:
Object
  • Object
show all
Defined in:
lib/cresip/echo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, payload) ⇒ Echo

Returns a new instance of Echo.



10
11
12
13
# File 'lib/cresip/echo.rb', line 10

def initialize(header, payload)
    @header = header
    @payload = payload
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



15
16
17
# File 'lib/cresip/echo.rb', line 15

def header
  @header
end

#payloadObject (readonly)

Returns the value of attribute payload.



15
16
17
# File 'lib/cresip/echo.rb', line 15

def payload
  @payload
end

Instance Method Details

#is_response?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cresip/echo.rb', line 21

def is_response?
    @header.type == :echo_response
end

#responseObject



25
26
27
28
29
30
# File 'lib/cresip/echo.rb', line 25

def response
    head = PacketHeader.new
    head.packet_type = PacketTypes[:echo_response]
    head.packet_size = @payload.length
    Echo.new(head, @payload)
end

#to_binary_sObject



32
33
34
# File 'lib/cresip/echo.rb', line 32

def to_binary_s
    "#{@header.to_binary_s}#{@payload}"
end

#typeObject



17
18
19
# File 'lib/cresip/echo.rb', line 17

def type
    @header.type
end