Working with NDK

liortal53
liortal53
edited July 2013 in Native
Hi

I am trying to work with the Android SDK of Photon Cloud.

The code comes with a sample that is very limited and exposes a limited number of methods through JNI.

How should i get started integrating your library into my code?

Comments

  • Hi liortal53.

    I don't think that I get you question. The Photon client SDK for Android NDK provides the full Photon C++ client API and is not limited by the JNI. Every C or C++ app for Android has to use a tiny bit of Java code via JNI. That code in the samples isn't anything Photon specific and aside from stylistic preferences should not differ from what other Android apps also do.
    Anything network related is encapsulated away into its own classes and files like for example NetworkLogic.cpp in demo_loadbalancing which many Photon users just copy and paste into their own projects as a base to start with.
  • My problem is that our code is Java based (most of it).

    I am looking for the best way to work with the SDK from our Java app. For example, i am not sure if it's such a good idea to ping-pong between Java and native code at a high frequency, perhaps it is better off to write a message loop in the native side to keep reading messages from Photon, etc.

    Anyway i am not 100% sure how to start...
  • Well, although it may be possible to use the Photon Android C++ client lib from Java game code through JNI, I think its preferable to use the same language for the network related and the rest of the game code. You could use the Photon Android Java client lib (the SDK without "NDK" in its name) instead of the C++ one to keep all your code in Java.

    Have you ruled that out, because you want to use the same network code in your C# editor on PC and your Java game on Android ( viewtopic.php?f=8&t=2817 )?

    We don't have any experience in using the JNI to call C++ code from Java code, but googling for something like JNI call c++ from java should provide you with all needed info.