Lets assume that you already have JRuby on your machine. To gain access to Java libraries distributed via Maven you need to install a special gem :
jruby -S gem install ruby-maven
Then you should install Smack API library:
jruby -S gem install mvn:org.igniterealtime.smack:smack
Please notice the special prefix "mvn:". You can also use it in Bundler's Gemfile to reference Java libraries once you have ruby-maven gem installed.
Now lets write a simple program to utilize the just installed library. Make sure you already have a valid Jabber and ICQ account. Also don't forget to register the latter via some Jabber-to-ICQ transport.
require 'java'
require 'rubygems'
require 'mvn:org.igniterealtime.smack:smack'
jabber_server = "jabber.dn.ua"
jabber_account_id = "my_jabber_id"
jabber_account_password = "**********"
icq_transport_server = "icq.jabber.dn.ua"
icq_account_id = "1234567890"
conn = org.jivesoftware.smack.XMPPConnection.new(jabber_server)
conn.connect
conn.login(jabber_account_id, jabber_account_password)
cm = conn.chat_manager
def self.processMessage(chat, message)
puts message
end
chat = cm.create_chat("#{icq_account_id}@#{icq_transport_server}", self)
chat.send_message("Hello!")
1 comment:
Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article.
Thanks for sharing such a nice info.I hope you will share more information like this. please keep on sharing!
internship in chennai
internship in chennai for cse
internship for mba in chennai
internship in chennai for hr
internship in chennai for mba
companies for internship in chennai
internship in chennai for ece
paid internship in chennai
internship in chennai for biotechnology
internship in chennai for b.com students
Post a Comment