Class: EventMachine::CallsBackToEM

Inherits:
Rev::TCPSocket show all
Defined in:
lib/revem.rb

Defined Under Namespace

Classes: ConnectTimer

Constant Summary

Constants inherited from Rev::IO

Rev::IO::INPUT_SIZE

Instance Attribute Summary

Attributes inherited from Rev::TCPSocket

#address_family, #remote_addr, #remote_host, #remote_port

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rev::TCPSocket

#initialize, #peeraddr, precreate

Methods inherited from Rev::Socket

#attach

Methods inherited from Rev::IO

#attach, #attached?, #close, #closed?, #detach, #disable, #enable, #enabled?, #evloop, #initialize, #output_buffer_size, #write

Methods included from Rev::Meta

#event_callback, #watcher_delegate

Constructor Details

This class inherits a constructor from Rev::TCPSocket

Class Method Details

.connect(*args) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/revem.rb', line 171

def self.connect *args
  a = super *args
  # the connect timer currently kills TCPServer classes.  I'm not sure why.
  #@connection_timer = ConnectTimer.new(14) # needs to be at least higher than 12 :)
  #@connection_timer.parent = a
  #@connection_timer.attach(Rev::Loop.default)
  a
end

Instance Method Details

#call_back_to_this(parent) ⇒ Object



128
129
130
131
# File 'lib/revem.rb', line 128

def call_back_to_this parent
  @call_back_to_this = parent
  parent.post_init
end

#connection_has_timed_outObject



138
139
140
141
142
# File 'lib/revem.rb', line 138

def connection_has_timed_out
  return if closed?
  close unless closed? # wonder if this works when you're within a half-connected phase.  I think it does.  What about TCP state?
  @call_back_to_this.unbind
end

#failObject



166
167
168
169
# File 'lib/revem.rb', line 166

def fail
  #@connection_timer.detch if @connection_timer
  @call_back_to_this.unbind
end

#on_closeObject



150
151
152
# File 'lib/revem.rb', line 150

def on_close
  @call_back_to_this.unbind # about the same ltodo check if they ARE the same here
end

#on_connectObject



133
134
135
136
# File 'lib/revem.rb', line 133

def on_connect
  # @connection_timer.detach if @connection_timer # won't need that anymore :) -- with server connecteds we don't have it, anyway
  @call_back_to_this.connection_completed if @call_back_to_this # TODO should server accepted's call this? They don't currently [and can't, since on_connect gets called basically in the initializer--needs some code love for that to happen :)
end

#on_connect_failedObject



158
159
160
# File 'lib/revem.rb', line 158

def on_connect_failed
  fail
end

#on_read(data) ⇒ Object



162
163
164
# File 'lib/revem.rb', line 162

def on_read(data)
  @call_back_to_this.receive_data data
end

#on_resolve_failedObject



154
155
156
# File 'lib/revem.rb', line 154

def on_resolve_failed
  fail
end

#on_write_completeObject



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

def on_write_complete; close if @should_close_after_writing; end

#should_close_after_writingObject



146
147
148
# File 'lib/revem.rb', line 146

def should_close_after_writing
  @should_close_after_writing = true;
end