Class: EventMachine::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/revem.rb

Class Method Summary collapse

Instance Method Summary collapse

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_writingObject

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_peernameObject



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_initObject

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

#unbindObject

Callback fired when connection is closed



194
# File 'lib/revem.rb', line 194

def unbind; end