Add Commands to the Genvid Plugin

A GenvidPlugin object with session sub-section commands.

Commands let you tell your game to do specific things from a separate website, such as an administrator site.

Unlike events, commands go directly from the website to your game without a MapReduce system. This makes it possible to send individual instructions to the game with minimal delay.

Caution

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

Engine Integration

A GenvidCommands object.
  1. Drag and drop a Commands Listener prefab into GenvidPlugin as a child of the GenvidPlugin.

  2. The Commands Listener has a Listeners section. Drag and drop your current GenvidCommandParameters assets into this field.

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

  4. Open one element and drag and drop your current GenvidCommandParameters asset in the Command field.

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

    • A string.

    • A second string.

    • An integer pointer.

  6. Drag and drop the object with your script into the On Command 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: Id of the command.

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

    • Second String: Results of the command.

    • IntPtr: Specific pointer used for the callback.

    The public function tells your game how to interpret commands sent from an external website. Commands are generally used for administrative functions and what they do is completely up to you. You can see examples of commands on the sample admin website.

Remember to implement your created commands in your website. You can find examples on the sendCommands page. The web-admin.js file in our Web Sample also illustrates this in more detail.