Class: Vines::Config::Port

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/vines/config/port.rb

Direct Known Subclasses

ClientPort, ComponentPort, HttpPort, ServerPort

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#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

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/vines/config/port.rb', line 8

def config
  @config
end

#settingsObject (readonly)

Returns the value of attribute settings.



8
9
10
# File 'lib/vines/config/port.rb', line 8

def settings
  @settings
end

#streamObject (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

#startObject



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