Class: EventMachine::RTMP::ConnectRequest
- Inherits:
-
Request
- Object
- ConnectionDelegate
- Request
- EventMachine::RTMP::ConnectRequest
- Defined in:
- lib/em-rtmp/connect_request.rb
Constant Summary collapse
- DEFAULT_PARAMETERS =
{ app: '', flashVer: 'WIN 10,1,85,3', swfUrl: '', tcUrl: '', fpad: false, capabilities: 239, audioCodecs: 3191, videoCodecs: 252, videoFunction: 1, pageUrl: nil, objectEncoding: 3 }
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#audioCodecs ⇒ Object
Returns the value of attribute audioCodecs.
-
#capabilities ⇒ Object
Returns the value of attribute capabilities.
-
#flashVer ⇒ Object
Returns the value of attribute flashVer.
-
#fpad ⇒ Object
Returns the value of attribute fpad.
-
#objectEncoding ⇒ Object
Returns the value of attribute objectEncoding.
-
#pageUrl ⇒ Object
Returns the value of attribute pageUrl.
-
#swfUrl ⇒ Object
Returns the value of attribute swfUrl.
-
#tcUrl ⇒ Object
Returns the value of attribute tcUrl.
-
#videoCodecs ⇒ Object
Returns the value of attribute videoCodecs.
-
#videoFunction ⇒ Object
Returns the value of attribute videoFunction.
Attributes inherited from Request
Attributes inherited from ConnectionDelegate
Instance Method Summary collapse
- #command_message ⇒ Object
-
#initialize(connection) ⇒ ConnectRequest
constructor
Initialize the request and set sane defaults for an RTMP connect request (transaction_id, command, header values).
-
#parameters ⇒ Object
Construct a list of parameters given our class attributes, used to form the connect message object.
-
#send ⇒ Object
Given the specific nature of a connect request, we can just set the message values to our params then encode that as our body before sending.
Methods inherited from Request
#chunk_count, #chunk_size, #chunks, #header_length_for_chunk, #send_chunk, #update_header
Methods inherited from ConnectionDelegate
#bytes_waiting, #change_state, #read, #write
Methods included from IOHelpers
#read_bitfield, #read_double_be, #read_int29, #read_safe, #read_uint16_be, #read_uint24_be, #read_uint32_be, #read_uint32_le, #read_uint8, #write_bitfield, #write_double_be, #write_int29, #write_uint16_be, #write_uint24_be, #write_uint32_be, #write_uint32_le, #write_uint8
Constructor Details
#initialize(connection) ⇒ ConnectRequest
Initialize the request and set sane defaults for an RTMP connect request (transaction_id, command, header values)
Returns nothing
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/em-rtmp/connect_request.rb', line 28 def initialize(connection) super connection self.header.channel_id = 3 self.header. = :amf0 self.header self..version = 0 self..transaction_id = 1 self..command = "connect" callback do |res| Logger.debug "rtmp connect failed, becoming ready" @connection.change_state :ready end errback do |res| Logger.debug "rtmp connect failed, closing connection" @connection.close_connection end end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def app @app end |
#audioCodecs ⇒ Object
Returns the value of attribute audioCodecs.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def audioCodecs @audioCodecs end |
#capabilities ⇒ Object
Returns the value of attribute capabilities.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def capabilities @capabilities end |
#flashVer ⇒ Object
Returns the value of attribute flashVer.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def flashVer @flashVer end |
#fpad ⇒ Object
Returns the value of attribute fpad.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def fpad @fpad end |
#objectEncoding ⇒ Object
Returns the value of attribute objectEncoding.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def objectEncoding @objectEncoding end |
#pageUrl ⇒ Object
Returns the value of attribute pageUrl.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def pageUrl @pageUrl end |
#swfUrl ⇒ Object
Returns the value of attribute swfUrl.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def swfUrl @swfUrl end |
#tcUrl ⇒ Object
Returns the value of attribute tcUrl.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def tcUrl @tcUrl end |
#videoCodecs ⇒ Object
Returns the value of attribute videoCodecs.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def videoCodecs @videoCodecs end |
#videoFunction ⇒ Object
Returns the value of attribute videoFunction.
21 22 23 |
# File 'lib/em-rtmp/connect_request.rb', line 21 def videoFunction @videoFunction end |
Instance Method Details
#command_message ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/em-rtmp/connect_request.rb', line 59 def cm = RocketAMF::Values::CommandMessage.new cm.operation = 5 cm.correlationId = "" cm. = 0 cm.timeToLive = 0 cm. = UUID.random cm.body = {} cm.destination = "" cm.headers = { "DSMessagingVersion" => 1, "DSId" => "my-rtmps" } cm end |
#parameters ⇒ Object
Construct a list of parameters given our class attributes, used to form the connect message object.
Returns a Hash of symbols => values
54 55 56 57 |
# File 'lib/em-rtmp/connect_request.rb', line 54 def parameters instance_values = Hash[instance_variables.map {|k| [k.to_s[1..-1].to_sym, instance_variable_get(k)]}] DEFAULT_PARAMETERS.merge instance_values.select {|k,v| DEFAULT_PARAMETERS.key? k } end |
#send ⇒ Object
Given the specific nature of a connect request, we can just set the message values to our params then encode that as our body before sending.
Returns the result of super
76 77 78 79 80 |
# File 'lib/em-rtmp/connect_request.rb', line 76 def send self..values = [parameters, false, "nil", "", ] self.body = .encode super end |