Jigar Bhatt
Jigar Bhatt

Reputation: 4650

How to build a new jabber client in ruby on rails 4?

Create new jabber client in ruby on rails 4?

I just know how to send messages between clients and build connection but this clients are creating by me from ejabber site statically.

So i want to create client dynamically from ruby coding.

jid = Jabber::JID.new('user')
client = Jabber::Client.new(jid)
client.connect('ip',5222)
client.auth('password')
client.send(Jabber::Presence.new.set_show(:chat).set_status('Rails!'))
puts "Hurray...!!  Connected..!!"


# Send an Instant Message.
body = 'Hello from Rails'
to_jid = Jabber::JID.new('user')
message = Jabber::Message::new(to_jid, body).set_type(:normal).set_id('1')
client.send(message)

Using this my code i have created chat functionality but i created client in ejabber site manually not by code.

So i want to create new client via ruby code, can you help me?

Upvotes: 2

Views: 824

Answers (1)

Jigar Bhatt
Jigar Bhatt

Reputation: 4650

    client = Jabber::Client.new(Jabber::JID.new('demo@localhost'))
    client.connect(localhost,5222)
    client.register(password)

Upvotes: 2

Related Questions