Class: LogStash::Inputs::Xmpp
- Defined in:
- lib/logstash/inputs/xmpp.rb
Overview
This input allows you to receive events over XMPP/Jabber.
This plugin can be used for accepting events from humans or applications XMPP, or you can use it for PubSub or general message passing for logstash to logstash.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/logstash/inputs/xmpp.rb', line 36 def register require 'xmpp4r' # xmpp4r gem Jabber::debug = true if @debug @client = Jabber::Client.new(Jabber::JID.new(@user)) @client.connect(@host) # it is ok if host is nil @client.auth(@password.value) @client.send(Jabber::Presence.new.set_type(:available)) # load the MUC Client if we are joining rooms. require 'xmpp4r/muc/helper/simplemucclient' if @rooms && !@rooms.empty? end |
#run(queue) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/logstash/inputs/xmpp.rb', line 50 def run(queue) if @rooms @rooms.each do |room| # handle muc messages in different rooms @muc = Jabber::MUC::SimpleMUCClient.new(@client) @muc.join(room) @muc. do |time,from,body| @codec.decode(body) do |event| decorate(event) event["room"] = room event["from"] = from queue << event end end # @muc.on_message end # @rooms.each end # if @rooms @client. do |msg| # handle direct/private messages # accept normal msgs (skip presence updates, etc) if msg.body != nil @codec.decode(msg.body) do |event| decorate(event) # Maybe "from" should just be a hash: # { "node" => ..., "domain" => ..., "resource" => ... } event["from"] = "#{msg.from.node}@#{msg.from.domain}/#{msg.from.resource}" queue << event end end end # @client.add_message_callback sleep end |