Class: EventMachine::Connection
- Inherits:
-
Object
- Object
- EventMachine::Connection
- Defined in:
- lib/revem.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#close_connection(after_writing = false) ⇒ Object
Close the connection, optionally after writing.
-
#close_connection_after_writing ⇒ Object
Close the connection after all data has been written.
- #get_peername ⇒ Object
-
#heres_your_socket(instantiated_rev_socket) ⇒ Object
Callback fired when data is received def receive_data(data); end.
-
#post_init ⇒ Object
we will need to call ‘their functions’ appropriately – the commented out ones, here.
-
#send_data(data) ⇒ Object
Send data to the current connection – called by them.
-
#unbind ⇒ Object
Callback fired when connection is closed.
Class Method Details
.new(*args) ⇒ Object
183 184 185 186 187 |
# File 'lib/revem.rb', line 183 def self.new *args allocate#.instance_eval do # initialize *args #end end |
Instance Method Details
#close_connection(after_writing = false) ⇒ Object
Close the connection, optionally after writing
209 210 211 212 |
# File 'lib/revem.rb', line 209 def close_connection(after_writing = false) return close_connection_after_writing if after_writing @wrapped_rev.close end |
#close_connection_after_writing ⇒ Object
Close the connection after all data has been written
215 216 217 |
# File 'lib/revem.rb', line 215 def close_connection_after_writing @wrapped_rev.output_buffer_size.zero? ? @wrapped_rev.close : @wrapped_rev.should_close_after_writing end |
#get_peername ⇒ Object
219 220 221 222 |
# File 'lib/revem.rb', line 219 def get_peername family, port, host_name, host_ip = @wrapped_rev.peeraddr Socket.pack_sockaddr_in( port, host_ip) # pack it up :) end |
#heres_your_socket(instantiated_rev_socket) ⇒ Object
Callback fired when data is received def receive_data(data); end
198 199 200 201 |
# File 'lib/revem.rb', line 198 def heres_your_socket instantiated_rev_socket instantiated_rev_socket.call_back_to_this self @wrapped_rev = instantiated_rev_socket end |
#post_init ⇒ Object
we will need to call ‘their functions’ appropriately – the commented out ones, here
Callback fired when connection is created
191 |
# File 'lib/revem.rb', line 191 def post_init; end |
#send_data(data) ⇒ Object
Send data to the current connection – called by them
204 205 206 |
# File 'lib/revem.rb', line 204 def send_data(data) @wrapped_rev.write data end |
#unbind ⇒ Object
Callback fired when connection is closed
194 |
# File 'lib/revem.rb', line 194 def unbind; end |