简体   繁体   中英

Best way to create a Android XMPP chat client in Unity3D

I am trying to create a iOS and Android XMPP chat client using Unity/C#/Mono. I got a fully functional chat client working for iOS using Jabber.net, but it does not work for Android. So does anyone have any idea of a library that works with Unity/C# for Android?

This post discusses Android and XMPP solutions, but have not found any way of connecting this to Unity: Android and XMPP: Currently available solutions

This is my question related to getting Jabber.net working for Android with Unity: Jabber.net on Unity/Android error (No JNI_OnLoad found in /system/lib/libc.so, skipping init)

Since nobody have answered here I how I solved it:

  1. ASmack for Android in a new Android project in eclipse
  2. Build a custom wrapper for ASmack with the basic public methods for login,logout,send messages et.c.
  3. Extract as jar library.
  4. Import jar into Unity3D
  5. Use Unity3D's AndroidJNI methods to call the public methods of the jar
  6. Callbacks are set inside the Java-wrapper and call with "UnityPlayer.UnitySendMessage()" (classes.jar from Unity app package have to be imported into Eclipse project to compile)
  7. Success!

A bit work is required and takes some time to debug and build, but it does work.

Instead of all this manipulation with ASmack I recommend to use MatriX XMPP SDK . We are using this library for our Unity projects.

And it works on Win, Mac, iOS, Android without any special manipulation. We have only 1 problem with this lib - can't make it work on in WebPlayer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM