Is Cocos2d-x still supported for Realtime?

When I go on the SDK download page, it seems to be supported but when you end up trying to download it, it points to an empty section of the page and there is no way to download the SDK.

I could always use the Android/Windows/ios seperate version and integrate them manually, but if it is already done, that would save me some time

Thanks

Answers

  • Kaiserludi
    Kaiserludi admin
    edited March 2022

    Hi @Hatan.

    Yes, cocos2d-x is supported.

    We never offered a dedicated cocos-integration. It has always been the current way:

    We offer Client SDKs that can be used with cocos2d-x, but we don't offer a dedicated cocos2d-x package as there is really no point in having a separate package for cocos2d-x. It does not require anything special. Just add the Photon libs to your project dependencies and include the headers, like you would do in any other C++ project as well.

    The Client SDKs for Android, iOS and Windows all include various demo projects and 3 of these demos (demo-chat, demo_memory and demo_particle) actually use cocos2d-x themselves for their graphical output so you could have a look at their project settings if you are looking for a blueprint.

  • Thanks. I was able to do the setup for Windows and make it work. I am struggling with Android though. I am trying to follow the guide here:

    But it seems quite outdated.


    The compile flags mentioned for APP_STL are no longer supported. So I am using c++_static instead (which is the default for Cocos)

    The folder: $(call import-add-path-optional, $(shell pwd)/../../../../Photon-cpp/src/android) does not exist

    I am trying with this one instead: $(call import-add-path-optional, ./../../../Photon-Android/Photon-cpp/lib)
    But this line: $(call import-module,photon-cpp-prebuilt)
    

    is causing the NDK to fail like:

    C:\game\openworld\proj.android\app\jni\Android.mk:134: *** Android NDK: Aborting.  . Stop.

    If I try to import it with the full path like

    $(call import-module,./../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt)
    

    I get other problems like:

    GNUMAKE: Expected exactly one -o file in compile step: com.android.build.gradle.external.gnumake.CommandClassifier$NativeCompilerBuildTool@2e2e958a

    but received: 

    mmon-cpp-static-prebuilt

    ....


    It is unclear exactly what has to be done to setup Android properly. And there are no android.mk or application.mk in the demos to see what is being done there.

    Any idea?


    Thanks

  • Hatan
    Hatan
    edited December 2021

    So... I was able to move forward but I am still stuck.

    After multiple tries and searches on the internet, I think I end up with something that should work, but it does not:

    I do have:

    LOCAL_STATIC_LIBRARIES += loadbalancing-cpp-static-prebuilt
    LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/libcrypto_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a \
    $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/libssl_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a \
    $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/libwebsockets_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a \
    ...
    

    in the loadbalancing, common and photon prebuilt android.mk I also changed:

    LOCAL_SRC_FILES     := libloadbalancing-cpp-static_${APP_OPTIM}_android_$(TARGET_ARCH_ABI).a

    to

    LOCAL_SRC_FILES     := libloadbalancing-cpp-static_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a


    I end up with a lot of undefined reference:

    ../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a_libc++.a(EncryptorOpenSSL.o): In function `ExitGames::Photon::Internal::Encryption::Impl::Impl(ExitGames::Common::Logger const&, ExitGames::Common::JVector<unsigned char> const&, ExitGames::Common::JVector<unsigned char> const&, int)':

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:38: undefined reference to `eg_RAND_bytes'

     ../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a_libc++.a(EncryptorOpenSSL.o): In function `ExitGames::Photon::Internal::Encryption::handleErrors()':

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:99: undefined reference to `eg_ERR_print_errors_fp'

     ../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a_libc++.a(EncryptorOpenSSL.o): In function `ExitGames::Photon::Internal::Encryption::Impl::encrypt(ExitGames::Common::JVector<unsigned char> const&, ExitGames::Common::JVector<unsigned char> const&, unsigned char) const':

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:125: undefined reference to `eg_EVP_CIPHER_CTX_new'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:135: undefined reference to `eg_EVP_aes_256_cbc'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:135: undefined reference to `eg_EVP_EncryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:142: undefined reference to `eg_EVP_EncryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:150: undefined reference to `eg_EVP_EncryptFinal_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:155: undefined reference to `eg_EVP_CIPHER_CTX_free'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:183: undefined reference to `eg_EVP_CIPHER_CTX_new'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:187: undefined reference to `eg_EVP_aes_256_gcm'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:187: undefined reference to `eg_EVP_EncryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:193: undefined reference to `eg_EVP_CIPHER_CTX_ctrl'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:197: undefined reference to `eg_EVP_EncryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:204: undefined reference to `eg_EVP_EncryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:211: undefined reference to `eg_EVP_EncryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:219: undefined reference to `eg_EVP_EncryptFinal_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:225: undefined reference to `eg_EVP_CIPHER_CTX_ctrl'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:229: undefined reference to `eg_EVP_CIPHER_CTX_free'

     ../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a_libc++.a(EncryptorOpenSSL.o): In function `ExitGames::Photon::Internal::Encryption::Impl::decrypt(ExitGames::Common::JVector<unsigned char> const&, ExitGames::Common::JVector<unsigned char> const&, unsigned char) const':

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:257: undefined reference to `eg_EVP_CIPHER_CTX_init'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:282: undefined reference to `eg_EVP_CIPHER_CTX_new'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:292: undefined reference to `eg_EVP_aes_256_cbc'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:292: undefined reference to `eg_EVP_DecryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:299: undefined reference to `eg_EVP_DecryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:307: undefined reference to `eg_EVP_DecryptFinal_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:312: undefined reference to `eg_EVP_CIPHER_CTX_free'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:327: undefined reference to `eg_EVP_CIPHER_CTX_new'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:331: undefined reference to `eg_EVP_aes_256_gcm'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:331: undefined reference to `eg_EVP_DecryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:335: undefined reference to `eg_EVP_CIPHER_CTX_ctrl'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:339: undefined reference to `eg_EVP_DecryptInit_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:346: undefined reference to `eg_EVP_DecryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:353: undefined reference to `eg_EVP_DecryptUpdate'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:358: undefined reference to `eg_EVP_CIPHER_CTX_ctrl'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:365: undefined reference to `eg_EVP_DecryptFinal_ex'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:369: undefined reference to `eg_EVP_CIPHER_CTX_free'

     ../../../Photon-Android/Photon-cpp/lib/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_arm64-v8a_libc++.a(EncryptorOpenSSL.o): In function `ExitGames::Photon::Internal::Encryption::Impl::hmac(ExitGames::Common::JVector<unsigned char> const&) const':

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:394: undefined reference to `eg_EVP_sha256'

     D:\a\Android\Photon-cpp/jni/../src/Internal/Encryption/EncryptorOpenSSL.cpp:394: undefined reference to `eg_HMAC'

  • Hatan
    Hatan
    edited December 2021

    For more info. I also tried:

    include $(CLEAR_VARS)
    LOCAL_MODULE    := libcrypto
    LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/android/libcrypto_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE    := libssl
    LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/android/libssl_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a
    include $(PREBUILT_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE    := libwebsocket
    LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../Photon-Android/3rdparty/lib/android/libwebsockets_${APP_OPTIM}_android_$(TARGET_ARCH_ABI)_libc++.a
    include $(PREBUILT_STATIC_LIBRARY)
    
    ...
    
    LOCAL_STATIC_LIBRARIES += loadbalancing-cpp-static-prebuilt libcrypto libssl libwebsocket
    

    which is more clean. Still the same issue where it does not find those static libraries


    Edit:


    I found out...

    LOCAL_WHOLE_STATIC_LIBRARIES += libcrypto
    LOCAL_WHOLE_STATIC_LIBRARIES += libssl
    LOCAL_WHOLE_STATIC_LIBRARIES += libwebsocket
    LOCAL_STATIC_LIBRARIES += loadbalancing-cpp-static-prebuilt
    


    Those 3rd party had to be placed in the "whole" libraries