Skip to content
developers
Developer home

VISWOO DOCUMENTATION

Server functions

Draws, one-time codes, event counters and plugin data without a server of your own.

Most plugins’ server work is ready on the platform. The screen view and the phone page ask for it with call(action, payload):

Action Permission Effect
draw draw Weighted draw; daily limit per visitor on phones, cooldown between draws on screens
codes.issue codes Issues a one-time code ({ payload, days? }); not callable from the phone page
any other name server Sent to your own server as an action event (Your own server)

Otherwise plugin.unknown_action. With incomplete setup plugin.setup_incomplete; when the plugin is off or outside its date range plugin.not_live.

Define the pool from settings: prizes come from a settings array and the remaining stock is kept on the server. In the manifest, draw.pools.<name>; from is the path of the array, prize fields are field names in the array items, the rest are paths of values in the settings (JSON Pointer).

"draw": {
"pools": {
"default": {
"from": "/prizes",
"id": "id",
"label": "label",
"weight": "weight",
"stock": "stock",
"winning": "winning",
"codeDays": "/codeDays",
"limitPerVisitorPerDay": "/dailyLimit"
}
}
}
Field Meaning
weight Draw weight; 0 never comes up
stock Remaining count; unlimited if missing. Saving settings does not reset stock; changing a prize’s stock value restarts its count
winning Wins; with the codes permission the winner gets a code
active, startsAt, endsAt Closes the pool or ties it to a date range (plugin.pool_closed)
codeDays Code validity in days (1–90)
limitPerVisitorPerDay Draws per phone per day (default 1)
screenCooldownSeconds Wait between two draws on a screen (default 5)

Make weight, stock and winning x-viswoo-visibility: "server" so screens and phones do not see them.

Viswoo.player.call('draw').then(function (result) {
// { prizeId, label, winning, code?, expiresAt? }
});

Errors: plugin.pool_not_found, plugin.pool_closed, plugin.pool_empty (no prize left), plugin.limit_reached. The panel reads remaining stock with draw.stock().

Codes have 6 characters, upper-case letters and digits, with no look-alike characters (e.g. K7M2QX). They are issued automatically for winning draws and with codes.issue. The panel tab checks them at the till with codes.lookup and redeems with codes.redeem; a second redemption returns plugin.code_redeemed, an expired code plugin.code_expired. Redemptions go to the audit log.

report(name, count?) (events permission) keeps daily counters; names [a-z0-9_.-]{1,40}. The panel reads up to 90 days with events.summary(days). The player sends counts in batches and keeps them while offline.

With the data permission the panel tab and your own server read and write JSON documents for the plugin (Panel tab, Platform API). The screen view and phone page do not access data directly; if they need it, your server returns it in an action response.