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

XmppTop.png

XMPP/JABBER - Best protocol to Instant Messengers for B4A

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

ReferenceXMPP.jpg



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

V1.0.1:
- Fix bug username

V1.0.2:
- Create 4 for events (ErrorSendMessage,ErrorConnect,ErrorLogin,PresenceChanged)
-
Create Methods: ChangeStatus, ActivatePresence
- Implemented correction in case the Name is Null

*Obs: PresenceChanged depends of each server.
Was observed in tests that some servers do not support the "presence listener"


V1.0.3:
- Fix bug when use XMPP and MQTT together

V1.0.4:
- Fix bug when use XMPP in some cases with threads

XMPP
Author:
Alberto Iglesias - alberto@visualnet.inf.br
Version: 1.0.4
  • XMPP
    Events:
    • deliverycomplete (Message As String)
    • messageArrived (Message As String)
    • onConnect ()
    • onDisconnect ()
    • onDisconnect (Status as boolean As )
    • onInitialized ()
    • onLogin ()
    • ErrorSendMessage(Error As String)
    • ErrorConnect(Error As String)
    • ErrorLogin(Error As String)
    • PresenceChanged(Presence As String)
    Fields:
    • Host As String
      Name or IP of the Jabber/XMPP Server
    • JavaDebug As Boolean
      Enable/Disable Debug from Java Code
    • Port As Int
      Port of the Jabber/XMPP Server
    Methods:
    • About As String
      About the developer
    • Connect
      Connect to the Jabber/XMPP Server
    • ChangeStatus(int iStatus)
      Change the status of your client
    • 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

ScreenXMPP.jpg


Xmpp1.jpg


Xmpp2.png


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


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.





Version 1.0.4

Look others libraries in http://www.visualnet.inf.br/store


* Put in this link because this forum accept only 512k maximum.
 

Attachments

  • Example1.zip
    12.8 KB · Views: 610
  • Example3.zip
    13 KB · Views: 547
Last edited:

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Ok Alberto now it works !, but ....................

Why Name is = Null ?

If i use your username and password the name is .visualfriend@jabber.chaotic.de , but if i use pluto@jabber.chaotic.de as user , the name is null !
And, remain the problem that if pluto(web app) sees pippo (app) online and send a message , the message is not delivered untill pippo(app) send the createchat.
Furthermore, the web app immediately realizes if a user changes state from offline to online, while in the library there 'an event

anyway, good job!

Look the version 1.0.2
https://www.b4x.com/android/forum/threads/xmpp-jabber-best-protocol-to-im-for-b4a.52076
 

walterf25

Expert
Licensed User
Longtime User

MiguelAlvarez

Member
Licensed User
Longtime User
XMPP/JABBER - Best protocol to Instant Messengers for B4A

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

En dónde puedo encontrar la libreria XMPP????

ReferenceXMPP.jpg





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


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.


 

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

i installed jabber service (openfire) to my server.

i tried with app which i download from google market. it works well.

i have problem with library

i connected to server but cant pass to Login

i got this error "GetUser = null" and after this

cant create chat or get message
 

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello Alberto.

its Openfire on windows 2012.

i can try yours but for my project it should work with mine

thanks for help
 

Reids

Member
Licensed User
Longtime User
Hello I tried using jabber.hot-chilli.net as hosts
host is xmpp.alpha-labs.net or jabber.alpha-labs.net
but it not logged due network exception

B4X:
** Activity (main) Create, isFirst = true **
JAVA [Initialize] eventname = objXmpp
Log = [objXmpp_onInitialized]
JAVA [About]
Log = XMPP About = XMPP Library - By Alberto Iglesias (alberto@visualnet.inf.br)
JAVA [Version]
Log = XMPP Version = 1.0.3 ** DONATIONWARE **
** Activity (main) Resume **
JAVA [Connect] Connected to xmpp.alpha-labs.net Connection is secured? true
JAVA [GetHost]:xmpp.alpha-labs.net
GetHost = xmpp.alpha-labs.net
JAVA [IsSecureConnection]
JAVA [IsSecureConnection]: True
IsSecureConnection = true
Log = [objXmpp_onConnected]
JAVA [IsConnected]
JAVA [IsConnected]: True
JAVA [Login] ERROR:android.os.NetworkOnMainThreadException
JAVA [GetUser]:null
GetUser = null
JAVA [SendMessage] message = ** DONATIONWARE ** my message
Delivery Message = ** DONATIONWARE ** my message
Log = [objXmpp_DeliveryComplete]:** DONATIONWARE ** my message
JAVA [IsConnected]
JAVA [IsConnected]: True
JAVA [Login] ERROR:Xmpp exception reidsneoconflict(409)
JAVA [Login] ERROR DISCONNECT
JAVA [GetUser]:null
GetUser = null
** Activity (main) Pause, UserClosed = false **

sample work well on chaotic.de hosts but not work on other public hosts, give error "ERROR:android.os.NetworkOnMainThreadException" on logged in
I research on other site too, it need to changed either SDK 11 or SDK 14 but not work, I need use it to communicate to yahoo messenger or google talk
so I need working host with Y! Gtalk support

thank you




EDIT :
fixed by adding on create

If p.SdkVersion >= 9 Then
Dim r As Reflector
r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
r.Target = r.RunMethod("permitAll")
r.Target = r.RunMethod("build")
r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
End If


BUT :
message still cannot send to yahoo messenger
 
Last edited:

nw11

Member
Licensed User
Longtime User
Hello Alberto,

is there any chance to have this library for ios (b4i) ?
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User

Erwin Andersen

Member
Licensed User
Longtime User
XmppTop.png

XMPP/JABBER - Best protocol to Instant Messengers for B4A

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

ReferenceXMPP.jpg



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

V1.0.1:
- Fix bug username

V1.0.2:
- Create 4 for events (ErrorSendMessage,ErrorConnect,ErrorLogin,PresenceChanged)
-
Create Methods: ChangeStatus, ActivatePresence
- Implemented correction in case the Name is Null

*Obs: PresenceChanged depends of each server.
Was observed in tests that some servers do not support the "presence listener"


V1.0.3:
- Fix bug when use XMPP and MQTT together

XMPP
Author:
Alberto Iglesias - alberto@visualnet.inf.br
Version: 1.0.3
  • XMPP
    Events:
    • deliverycomplete (Message As String)
    • messageArrived (Message As String)
    • onConnect ()
    • onDisconnect ()
    • onDisconnect (Status as boolean As )
    • onInitialized ()
    • onLogin ()
    • ErrorSendMessage(Error As String)
    • ErrorConnect(Error As String)
    • ErrorLogin(Error As String)
    • PresenceChanged(Presence As String)
    Fields:
    • Host As String
      Name or IP of the Jabber/XMPP Server
    • JavaDebug As Boolean
      Enable/Disable Debug from Java Code
    • Port As Int
      Port of the Jabber/XMPP Server
    Methods:
    • About As String
      About the developer
    • Connect
      Connect to the Jabber/XMPP Server
    • ChangeStatus(int iStatus)
      Change the status of your client
    • 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

ScreenXMPP.jpg


Xmpp1.jpg


Xmpp2.png


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


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.





Version 1.0.3

* Put in this link because this forum accept only 512k maximum.


Hi,

If i need the source code...how much this cost ?

Thank you
 
Top