Class: Vines::Config::Port
- Inherits:
-
Object
- Object
- Vines::Config::Port
- Includes:
- Log
- Defined in:
- lib/vines/config/port.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(config, host, port, &block) ⇒ Port
constructor
A new instance of Port.
- #max_stanza_size(max = nil) ⇒ Object
- #start ⇒ Object
Methods included from Log
Constructor Details
#initialize(config, host, port, &block) ⇒ Port
Returns a new instance of Port.
16 17 18 19 20 21 22 |
# File 'lib/vines/config/port.rb', line 16 def initialize(config, host, port, &block) @config, @settings = config, {} instance_eval(&block) if block defaults = {:host => host, :port => port, :max_resources_per_account => 5, :max_stanza_size => 128 * 1024} @settings = defaults.merge(@settings) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/vines/config/port.rb', line 8 def config @config end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
8 9 10 |
# File 'lib/vines/config/port.rb', line 8 def settings @settings end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
8 9 10 |
# File 'lib/vines/config/port.rb', line 8 def stream @stream end |
Instance Method Details
#max_stanza_size(max = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/vines/config/port.rb', line 24 def max_stanza_size(max=nil) if max # rfc 6120 section 13.12 @settings[:max_stanza_size] = [10000, max].max else @settings[:max_stanza_size] end end |
#start ⇒ Object
33 34 35 36 37 |
# File 'lib/vines/config/port.rb', line 33 def start type = stream.name.split('::').last.downcase log.info("Accepting #{type} connections on #{host}:#{port}") EventMachine::start_server(host, port, stream, config) end |