Method: EventMachine::RTMP::ResponseRouter#route_response

Defined in:
lib/em-rtmp/response_router.rb

#route_response(response) ⇒ Object

Route any response to its proper destination. AMF responses are routed to their pending request. Chunk size updates the connection, others are ignored for now.

response - Response object to route or act on.

Returns nothing.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/em-rtmp/response_router.rb', line 79

def route_response(response)
  case response.header.message_type
  when :amf0
    response.message = Message.new version: 0
    response.message.decode response.body
    Logger.info "head: #{response.header.inspect}"
    Logger.info "amf0: #{response.message.inspect}"
    route_amf :amf0, response
  when :amf3
    response.message = Message.new version: 3
    response.message.decode response.body
    Logger.info "head: #{response.header.inspect}"
    Logger.info "amf3: #{response.message.inspect}"
    route_amf :amf3, response
  when :chunk_size
    connection.chunk_size = response.body.unpack('N')[0]
    Logger.info "setting chunk_size to #{chunk_size}"
  when :ack_size
    ack_size = response.body.unpack('N')[0]
    Logger.info "setting ack_size to #{ack_size}"
  when :bandwidth
    bandwidth = response.body[0..3].unpack('N')[0]
    bandwidth_type = response.body[4].unpack('c')[0]
    Logger.info "setting bandwidth to #{bandwidth} (#{bandwidth_type})"
  else
    Logger.info "cannot route unknown response: #{response.inspect}"
  end
end