Class: EventMachine::RTMP::ConnectionDelegate

Inherits:
Object
  • Object
show all
Includes:
IOHelpers
Defined in:
lib/em-rtmp/connection_delegate.rb

Direct Known Subclasses

Handshake, Heartbeat, Request, Response, ResponseRouter

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ ConnectionDelegate

Initialize the connection delegate by storing a reference to the connection

Returns nothing.



15
16
17
18
# File 'lib/em-rtmp/connection_delegate.rb', line 15

def initialize(connection)
  @connection = connection
  @state = :none
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#bytes_waitingObject

Obtain the number of bytes waiting in the buffer

Returns an Integer



45
46
47
# File 'lib/em-rtmp/connection_delegate.rb', line 45

def bytes_waiting
  @connection.bytes_waiting
end

#change_state(state) ⇒ Object

Used to track changes in state

Returns nothing



52
53
54
55
56
# File 'lib/em-rtmp/connection_delegate.rb', line 52

def change_state(state)
  return if @state == state
  Logger.info "state changed from #{@state} to #{state}", caller: caller
  @state = state
end

#read(length) ⇒ Object

Reads from the connection buffer

length - Bytes to read

Returns the result of the read



27
28
29
# File 'lib/em-rtmp/connection_delegate.rb', line 27

def read(length)
  @connection.read length
end

#write(data) ⇒ Object

Writes to the connection socket

data - Data to write

Returns the result of the write



38
39
40
# File 'lib/em-rtmp/connection_delegate.rb', line 38

def write(data)
  @connection.write data
end