Class: Jabber::Framework::Base

Class | Jabber::Framework::Base
In: | lib/xmpp4r/framework/base.rb
Parent: | Object

### Methods

helper new on_unhandled_iq

### Attributes

stream | [RW] |

### Public Class methods

helper(name, klass=nil, &factory)

[Source]

        # File lib/xmpp4r/framework/base.rb, line 7
     7:       def self.helper(name, klass=nil, &factory)
     8:         if klass.nil? and factory.nil?
     9:           raise "helper #{name} needs a class or factory"
    10:         end
    11:
    12:         define_method(name) do
    13:           @helpers_lock.synchronize do
    14:             if @helpers[name]
    15:               @helpers[name]
    16:             else
    17:               if factory
    18:                 @helpers[name] = instance_eval { factory.call(@stream) }
    19:               elsif klass
    20:                 @helpers[name] = klass.new(@stream)
    21:               else
    22:                 raise
    23:                 end
    24:             end
    25:           end
    26:         end
    27:       end

new(stream)

[Source]

        # File lib/xmpp4r/framework/base.rb, line 31
    31:       def initialize(stream)
    32:         @stream = stream
    33:         @helpers = {}
    34:         @helpers_lock = Mutex.new
    35:
    36:         # Catch all unhandled iq stanzas (lowest priority)
    37:         @stream.add_iq_callback(-1000, self, &method(:on_unhandled_iq))
    38:       end

### Public Instance methods

on_unhandled_iq(iq)

[Source]

        # File lib/xmpp4r/framework/base.rb, line 40
    40:       def on_unhandled_iq(iq)
    41:         if iq.type == :get or iq.type == :set
    42:           answer = iq.answer(true)
    43:           answer.type = :error
    44:           answer.add(ErrorResponse.new('feature-not-implemented'))
    45:           @stream.send(answer)
    46:
    47:           true
    48:         else
    49:           false
    50:         end
    51:       end

[Validate]