Add Requests to the Genvid Plugin

A GenvidPlugin object with session sub-section commands.

Requests let you tell your game answers demands from a separate website, such as an administrator site, and reply to each of them.

Like commands, requests go directly from the website to your game without filtering. Each requests must be replied within a time limit for the requester to not receive an error.

Caution

We recommend limiting requests to an administrator or similarly access-controlled page.

Engine Integration

  1. Drag and drop a Requests Listener prefab into GenvidPlugin as a child of the GenvidPlugin.

  2. The Requests Listener has a Listeners section. Drag and drop your current Genvid Request Parameters assets into this field.

  3. Change the Listeners Size to the number of requests that you want to use.

  4. Open one element and drag and drop your current Genvid Request Parameters asset in the Request field.

  5. In the script receiving the request, create a public function that takes the following parameters in this order:

  6. Drag and drop the object with your script into the On Request Triggered box.

  7. From the dropdown list displaying No Function, select the game script and function you created.

  8. In your public function you can use the information received from the command:

    • First String: Topic of the request.

      Note: You’ll use this topic later when setting up your Requests configuration and website calls.

    • Second Object: Results of the request.

    • IntPtr: Specific pointer used for the callback.

    The public function tells your game how to interpret requests sent from an external website and how to response to them using the SubmitRequestReply method of the Session instance. Here an example:

        public void OnRequestGetState(string topic, GenvidSDK.RequestResult result, IntPtr uniqueID)
        {
            string replyTo = result.replyTo;
            string payload = Marshal.PtrToStringAnsi(result.data, result.dataSize);
            Debug.Log(String.Format("Received {0} about {1}.", payload, topic));
    
            GenvidPlugin.Instance.SessionManager.Session.SubmitRequestReply(topic, replyTo, "running");
        }
    

    Requests are generally used for administrative functions and what they do is completely up to you. You can see examples of requests on the sample admin website.

  9. Remember to implement your created requests in your website. You can find examples on the sendRequestGetState.