Class: EventMachine::RTMP::PendingRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/em-rtmp/pending_request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, connection) ⇒ PendingRequest

Create a new pending request from a request

Returns nothing



9
10
11
12
# File 'lib/em-rtmp/pending_request.rb', line 9

def initialize(request, connection)
  self.request = request
  self.connection = connection
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/em-rtmp/pending_request.rb', line 4

def connection
  @connection
end

#requestObject

Returns the value of attribute request.



4
5
6
# File 'lib/em-rtmp/pending_request.rb', line 4

def request
  @request
end

Class Method Details

.create(request, connection) ⇒ Object

Create a request and add it to the pending requests hash

request - Request to add

Returns the request



38
39
40
41
42
43
44
# File 'lib/em-rtmp/pending_request.rb', line 38

def self.create(request, connection)
  message_type = request.header.message_type
  transaction_id = request.message.transaction_id.to_i
  connection.pending_requests[message_type] ||= {}
  connection.pending_requests[message_type][transaction_id] = new(request, connection)
  connection.pending_requests[message_type][transaction_id]
end

.find(message_type, transaction_id, connection) ⇒ Object

Find a request by message type and transaction id

message_type - Symbol representing the message type (from header) transaction_id - Integer representing the transaction id

Returns the request or nothing



27
28
29
30
31
# File 'lib/em-rtmp/pending_request.rb', line 27

def self.find(message_type, transaction_id, connection)
  if connection.pending_requests[message_type]
    connection.pending_requests[message_type][transaction_id.to_i]
  end
end

Instance Method Details

#deleteObject

Delete the current request from the list of pending requests

Returns nothing



17
18
19
# File 'lib/em-rtmp/pending_request.rb', line 17

def delete
  connection.pending_requests[request.header.message_type].delete(request.message.transaction_id.to_i)
end