Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 680
Sunkas Avatar asked Aug 29 '12 07:08

Sunkas


2 Answers

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.

like image 150
Sunkas Avatar answered Sep 28 '22 23:09

Sunkas


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

like image 24
Suvitruf - Andrei Apanasik Avatar answered Sep 29 '22 00:09

Suvitruf - Andrei Apanasik