Jump to content

Callback from Api.Init not working correctly


KospY

Recommended Posts

Just started to take a look about integrating the Viveport SDK(1.7.10) in my Unity project (2019.1.2) and it seem that the callback from Api.Init(InitStatusHandler, APP_ID) don't get called as it should.

I assume it's because I didn't installed Viveport yet (the app try to open it) but if I cancel 3 times the opening request (by pressing echap) the app continue to run as nothing happened (callback don't get called).

 

I'm maybe missing something, but it seem to be a pretty serious issue as it allow to go through the DRM super easily (we need to wait this callback to check the licence).

 

To be sure, I tried on a blank project with the ViveportDemo.cs script and the behaviour is the same.

 

Thanks for your help!

 

Link to comment
Share on other sites

  • 2 weeks later...

Hello Kospy,

 

The ViveportDemo.cs script is an example to help devs get started. Currently the script does not handle if there is an Init or DRM failure which is expected to be implemented by the developer. Usually the developer will have the application quit or show a message to the user for the issue.

 

In the examples on the DRM page there is the lines "// Handle error and close your game." Here is where you can call "Application.Quit();". Otherwise, if the DRM and Init is successfull you can then launch into the game.

 

https://developer.viveport.com/documents/sdk/en/api_drm.html

Link to comment
Share on other sites

Yeah I know I need to handle the application exit myself, it's not the issue, the issue is the callback from Api.Init don't get called at all, so I can't check anything.

I assume it's because viveport is not installed on my computer, as I got this request 3 times after starting the application:

 

 

 

 

 

 

 

 

 

 

To reproduce just don't install viveport, use the example script below, start the application and press echap 3 times when the application try to open Viveport.

 

using UnityEngine;using System;using Viveport;public class ViveportDemo : MonoBehaviour{   static string VIVEPORT_ID = "bd67b286-aafc-449d-8896-bb7e9b351876";
// Use this for initialization void Start () { Api.Init(InitStatusHandler, VIVEPORT_ID); } private static void InitStatusHandler(int nResult) { Viveport.Core.Logger.Log("Init(): " + nResult); }}

You should not see any "Init(): XX" line in the log because the callback don't get called.

 

Link to comment
Share on other sites

Hey KospY,

I see what you're saying and thanks for sharing the sample code. We're working on improving the Viveport SDK, samples, and documentation and this is a great example of how it can be improved.

 

One thing I want to check with you is what parts of the Viveport API will you be using? If it's only for the DRM then it's worth noting that you can use your existing Steam build and we provide a DRM wrapper that you can use without integrating the Viveport SDK.

 

 

 

 

 

 

 

 

 

 


Regarding the sample code, I've written a version that checks for successfull initialzation after 10 seconds and quits if the callback has not completed:

 

using UnityEngine;using System;using Viveport;public class InitTest : MonoBehaviour{    static string VIVEPORT_ID = "bd67b286-aafc-449d-8896-bb7e9b351876";    private static bool bInitComplete = false;    void Start()    {        Api.Init(InitStatusHandler, VIVEPORT_ID);        Invoke("CheckInitStatus", 10);    }    private static void InitStatusHandler(int nResult)    {        Debug.LogWarning("INIT: " + nResult);        Viveport.Core.Logger.Log("Init(): " + nResult);        if (nResult == 0)            bInitComplete = true;    }    static void CheckInitStatus()    {        Debug.Log("check init status");        if (!bInitComplete)        {            Debug.LogWarning("init failed");            Application.Quit();        }    }}
Link to comment
Share on other sites

Thanks for your reply.

I'm using it for the DRM. I could use the wrapper, but my application is using .Net (Unity) so I was following your recommendations.

Sure I could wait 10 sec to check if I got the callback but it seem more like a workaround than a real solution. I think this issue should be handled by Api.Init() directly (the callback should always return).

Anyway I assume that the majority of devs are using your samples so I wanted to warn you about a potential issue allowing people to get around the DRM easily.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...