Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Anyone porting RatNet library to Unity?

Discussion in 'Multiplayer' started by song_jiang, Apr 21, 2016.

  1. song_jiang

    song_jiang

    Joined:
    Sep 18, 2015
    Posts:
    6
    I'm trying hard on this.
    RakNet seems quite stable and I'm trying to porting ti to Unity.
    Following the instruction provided by Raknet, I've succeed porting to arch i386. I can use mono to run native code which Raknet provides. But when porting to iOS, some errors occur :(
    I'm just wondering if anybody also doing this thing?
     
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,663
    Old unity networking is actually built around raknet. It's like a wrapper I guess, and you interact from outside, through your scripting.

    I Google'd a bit and see older threads talking about others trying to get something like your saying going, but couldn't find much info on any existing assets that implement it "from the outside". I didn't look thoroughly though.
     
  3. song_jiang

    song_jiang

    Joined:
    Sep 18, 2015
    Posts:
    6
    Yes, since old unity networking can use raknet, I guess at least it could be done.
    I used Swig to generate c++ wrapper for the RakNet and C# scripts to P/invoke the wrapper. But after switching to iOS and running in iPad I always get

    NotSupportedException: To marshal a manged method, please add an attribute named 'MonoPInvokeCallback' to the method definition.

    at RakNet.RakNetPINVOKE..cctor () [0x00000] in <filename unknown>:0

    at test.Start () [0x00000] in <filename unknown>:0

    Rethrow as TypeInitializationException: The type initializer for 'RakNet.RakNetPINVOKE.SWIGExceptionHelper' threw an exception.

    at RakNet.RakNetPINVOKE..cctor () [0x00000] in <filename unknown>:0

    at test.Start () [0x00000] in <filename unknown>:0

    Rethrow as TypeInitializationException: The type initializer for 'RakNet.RakNetPINVOKE' threw an exception.

    at test.Start () [0x00000] in <filename unknown>:0


    (Filename: currently not available on il2cpp Line: -1)
     
  4. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,663
    Welp, that's all over my head. I usually port stuff from other languages into c#, but never tried working like you are with stuff.

    Good luck!
     
  5. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I was also able to get raknet working via swig on windows / linux. I'm still working on mac. Haven't tested on any mobile platforms yet but if you have any luck please post back here!
     
  6. song_jiang

    song_jiang

    Joined:
    Sep 18, 2015
    Posts:
    6
    OK,still trying :(
     
  7. song_jiang

    song_jiang

    Joined:
    Sep 18, 2015
    Posts:
    6
    MonoPInvokeCallback solve the problem :)
    I'm really happy now
     
    ixdeveloper likes this.
  8. ixdeveloper

    ixdeveloper

    Joined:
    Jan 5, 2016
    Posts:
    14
    Hi @song_jiang, did you manage to get a working iOS build with RakNet? I'd be very interested in learning how you got MonoPInvokeCallback to work, I have managed to build a static library but when running on my device I get the error
    EntryPointNotFoundException: SWIGRegisterExceptionCallbacks_SharingClient

    I've posted some more details here:
    https://stackoverflow.com/questions/45783473/build-native-plugin-for-ios-using-swig

    Thanks!