Skip to content

Files

Latest commit

6e8ae9b · Nov 24, 2023

History

History

RandomValue

README.md

About the "RandomValue" sample

The "RandomValue" sample extension is a server extension that provides random numbers between zero and a configurable maximum.

The current maximum can be read/set using the RandomValue.MaxRandom symbol. The initial maximum is 1000. New random numbers are returned by the RandomValue.RandomValue symbol and are always smaller or equal to RandomValue.MaxRandom.

The extension configuration includes a single integer value (RandomValue.Config::maxRandom) that can be read directly from the extension configuration or using the RandomValue.MaxRandomFromConfig symbol. RandomValue.MaxRandom and RandomValue.Config::maxRandom are never synced automatically. The value in the extension configuration is only used as a persistent storage.

First steps:

Example requests

  1. Generate a new random number

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.RandomValue",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.RandomValue",
                "readValue": 32
            }
        ]
    }
  2. Get the currently configured maximum using the RandomValue.MaxRandom symbol

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.MaxRandom",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.MaxRandom",
                "readValue": 1000
            }
        ]
    }
  3. Change the current maximum using the RandomValue.MaxRandom symbol

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.MaxRandom",
                "writeValue": 1234,
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.MaxRandom",
                "readValue": 1000
            }
        ]
    }
  4. Get the value that is currently stored in the extension configuration using the RandomValue.MaxRandomFromConfig symbol

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.MaxRandomFromConfig",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.MaxRandomFromConfig",
                "readValue": 10
            }
        ]
    }
  5. Read the value that is currently stored in the extension configuration directly

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.Config::maxRandom",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.Config::maxRandom",
                "readValue": 10
            }
        ]
    }
  6. Change the value that is stored in the extension configuration

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "RandomValue.Config::maxRandom",
                "writeValue": 2048,
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "RandomValue.Config::maxRandom",
                "readValue": 2048
            }
        ]
    }