B4J Library XMPP/JABBER - Best protocol to IM for B4J

XMPPTopB4j.png


XMPP/JABBER - Best protocol to Instant Messengers for B4J

This library was made based on XMPP Protocol

Installation instructions:
- Copy the .xml and .jar(s) files to your custom libraries folder
- Select in your REFERENCED LIBRARIES

B4JScreen2.jpg




Version history:
V1.0.0 (First public release - Donationware):
- Initial version

XMPP
Author:
Alberto Iglesias - alberto@visualnet.inf.br
Version: 1
  • XMPP
    Events:
    • deliverycomplete (Message As String)
    • messageArrived (Message As String)
    • onConnect ()
    • onDisconnect ()
    • onDisconnect (Status as boolean As )
    • onInitialized ()
    • onLogin ()
    Fields:
    • Host As String
      Name or IP of the Jabber/XMPP Server
    • Port As Int
      Port of the Jabber/XMPP Server
    Methods:
    • About As String
      About the developer
    • Connect
      Connect to the Jabber/XMPP Server
    • CreateChat (userJID As String)
      Create Chat with the JIB User
    • Disconnect
      Disconnect from Jabber/XMPP Server
    • GetHost As String
      Returns the host name of the server where the XMPP server is running
    • GetRoster As List
      Get Roster List
    • GetUser As String
      Get the connection current user
    • Initialize (eventname As String)
      Initializing XMPP Object
    • IsConnected As Boolean
      Get a connection status
    • IsSecureConnection As Boolean
      Check if the connection is secure
    • Login (Username As String, Password As String)
      Login into to the Jabber/XMPP Server
    • SendMessage (message As String)
      Send a message into the chat
    • Version As String
      Get the Library Version
    Permissions:
    • android.permission.ACCESS_WIFI_STATE
    • android.permission.INTERNET

B4JScreen1.jpg



Xmpp1.jpg


Xmpp2.png


You can try your APP using web client in https://jwchat.org/

Look this video:


References:
http://xmpp.org/
https://jwchat.org/

* This version is fully functional, the only one difference is when sending a message the text "Donationware" is delivery with your message.
Please consider a simple €10 donation and I send to you the Library without "Donationware" text in a sendmessage method.


 

Attachments

  • Example1.zip
    2.1 KB · Views: 340
  • LibraryB4J_XMPP_100.zip
    326.6 KB · Views: 400
Last edited:

lymey

Active Member
Licensed User
Hi Alberto!
I am trying to run your example program and am getting the following in the Log:

Program started.
[objXmpp_onInitialized]
MQTT About = XMPP Library - By Alberto Iglesias (alberto@visualnet.inf.br)
MQTT Version = 1.0.0 ** DONATIONWARE **
May 05, 2015 7:02:50 PM org.jivesoftware.smack.provider.UrlProviderFileInitializer initialize
INFO: Loading providers for file [classpath:META-INF/core.providers]
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.provider.ExtensionInitializer] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.ServiceDiscoveryManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.XHTMLManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.muc.MultiUserChat] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.filetransfer.FileTransferManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.LastActivityManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.commands.AdHocCommandManager] specified in smack-config.xml could not be loaded:
May 05, 2015 7:02:50 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNING: A startup class [org.jivesoftware.smackx.ping.PingManager] specified in smack-config.xml could not be loaded:
Unexpected event (missing RaiseSynchronousEvents): objxmpp_onlogin

Then when I try and login to the server:


Then When I try and send a message:

Error occurred on line: 94 (main).
java.lang.NullPointerException
at com.visualnet.xmpp.SendMessage(xmpp.java:283)
at b4j.example.main._cmdsendmessage_action(main.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
at anywheresoftware.b4a.BA$2.run(BA.java:165)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1413246693.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1030870354.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/1232367853.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)

I have the libraries copied to the referenced libaries directory.

What have I missed?

Thanks for your help, if I can get this and the Android library working they will be very helpful!
 

lymey

Active Member
Licensed User
Hi Alberto,
I haven't tried the basic For Android version yet - the problem I am having is with B4J
 

lymey

Active Member
Licensed User
Hi Alberto,
I am using jdk1.8.0_45\bin\javac.exe, I was using 1.7 before also.
I still get all the same warning messages, but I can at least have a chat using the example app and Pidgin, and Process One's One Team client.
is there a plan to send and receive files?
May thanks
Paul
 

lymey

Active Member
Licensed User
That would be a shame,
I think having send/receive file functionality would make this an even more useful (and commercial) library.
I would be happy to donate more if it had that capability!
:)
 

tigrot

Well-Known Member
Licensed User
Hi Alberto,
I was testing your test APP on a W10 PC and get these errors:
B4X:
Waiting for debugger to connect...
Program started.
[objXmpp_onInitialized]
MQTT About = XMPP Library - By Alberto Iglesias (alberto@visualnet.inf.br)
MQTT Version = 1.0.0 ** DONATIONWARE **
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.provider.UrlProviderFileInitializer initialize
INFORMAZIONI: Loading providers for file [classpath:META-INF/core.providers]
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.provider.ExtensionInitializer] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.ServiceDiscoveryManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.XHTMLManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.muc.MultiUserChat] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.filetransfer.FileTransferManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.LastActivityManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.commands.AdHocCommandManager] specified in smack-config.xml could not be loaded:
apr 06, 2017 1:00:21 PM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
AVVERTENZA: A startup class [org.jivesoftware.smackx.ping.PingManager] specified in smack-config.xml could not be loaded:

Any idea?

Ciao
Mauro
 

Alberto Iglesias

Well-Known Member
Licensed User
Hello tigrot,

I saw maybe something is missing like java dependencies in this machine. It´s not the problem with b4j library, I´m using in windows 10 too.

https://community.igniterealtime.org/thread/47774

Try to update java machines or upgrade to the last one.

And check the permissions when install this dependencies.


best regards,

Alberto Iglesias
 

birnesoft

Active Member
Licensed User
Hello Alberto,
I have the same problem on a W10 PC, B4J 5.9, jdk1.8.0_66
Any idea?
Björn

B4X:
Waiting for debugger to connect...
Program started.
[objXmpp_onInitialized]
MQTT About = XMPP Library - By Alberto Iglesias (alberto@visualnet.inf.br)
MQTT Version = 1.0.0
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.provider.UrlProviderFileInitializer initialize
INFORMATION: Loading providers for file [classpath:META-INF/core.providers]
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.provider.ExtensionInitializer] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.ServiceDiscoveryManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.XHTMLManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.muc.MultiUserChat] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.filetransfer.FileTransferManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.LastActivityManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.commands.AdHocCommandManager] specified in smack-config.xml could not be loaded:
Okt 19, 2017 10:22:24 AM org.jivesoftware.smack.SmackConfiguration parseClassToLoad
WARNUNG: A startup class [org.jivesoftware.smackx.ping.PingManager] specified in smack-config.xml could not be loaded:
 
Top