Class: Iodine::Base::Listener

Inherits:
Protocol
  • Object
show all
Defined in:
lib/iodine/io.rb

Overview

the server listener Protocol.

Instance Attribute Summary

Attributes inherited from Protocol

#io, #locker, #options

Instance Method Summary collapse

Methods inherited from Protocol

#close, #closed?, each, #id, #initialize, #on_close, #on_message, #on_shutdown, #ping, #read, #set_timeout, #ssl?, #timeout?, #write

Constructor Details

This class inherits a constructor from Iodine::Protocol

Instance Method Details

#callObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/iodine/io.rb', line 38

def call
  begin
    n_io = nil
    loop do
      n_io = @io.accept_nonblock
      # @protocol.accept(n_io, @ssl)
      Iodine.run n_io, @ssl, &(@accept_proc)
    end
  rescue Errno::EWOULDBLOCK => e

  rescue => e
    n_io.close if n_io && !n_io.closed?
    @stop = true
    raise e
  end
end

#on_openObject



33
34
35
36
37
# File 'lib/iodine/io.rb', line 33

def on_open
  @protocol = Iodine.protocol
  @ssl = Iodine.ssl
  @accept_proc = @protocol.method(:accept)
end