Class: AptControl::Notify::Jabber

Inherits:
Object
  • Object
show all
Includes:
Jabber
Defined in:
lib/apt_control/notify.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Jabber

Returns a new instance of Jabber.



12
13
14
15
16
17
18
19
# File 'lib/apt_control/notify.rb', line 12

def initialize(options={})
  @jid      = options[:jid]
  @password = options[:password]
  @room_jid = options[:room_jid]
  @logger   = options[:logger]

  connect!
end

Instance Method Details

#connect!Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/apt_control/notify.rb', line 21

def connect!
  # ::Jabber::debug = true
  @logger.info("Jabber connecting with jid #{@jid}")
  @client = Client.new(JID.new(@jid))
  @client.connect
  @client.auth(@password)

  @muc = Jabber::MUC::SimpleMUCClient.new(@client)
  @muc.join(JID.new(@room_jid))
  @logger.info("joined room #{@room_jid}")
end

#message(msg) ⇒ Object



33
34
35
# File 'lib/apt_control/notify.rb', line 33

def message(msg)
  @muc.send(Message.new(nil, msg))
end