Class: Sendify

Inherits:
Object
  • Object
show all
Defined in:
lib/sendify.rb

Instance Method Summary collapse

Instance Method Details

#connect(jid, password, service, ip) ⇒ Object



10
11
12
13
14
15
# File 'lib/sendify.rb', line 10

def connect(jid,password,service,ip)
  client = Client.new(JID.new(jid))
  client.connect(ip)
  client.auth(password)
  client
end

#createNode(client, service, node) ⇒ Object



17
18
19
20
# File 'lib/sendify.rb', line 17

def createNode(client,service,node)
  pubsub = PubSub::ServiceHelper.new(client, service)
  pubsub.create_node(node)
end

#publish(client, service, node, element, msg) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/sendify.rb', line 22

def publish(client,service,node,element,msg)
  pubsub = PubSub::ServiceHelper.new(client, service)
  item = Jabber::PubSub::Item.new
  xml = REXML::Element.new(element)
  xml.text = msg
  item.add(xml)
  pubsub.publish_item_to(node, item)
end