Zebflow Docs
ws.session.tag
Zebflow Docs

ws.session.tag

Gives a session of a room tags, or takes them away

ws.session.tag [--room TEXT] [--session TEXT] [--tag TEXT…] [--untag TEXT…] → session

Gives a session of a room tags, or takes them away. A session's tags decide what it sees: a state path written with ws.state.put --visible-to team:red is sent only to sessions holding team:red (fog of war, a private hand, the grid cells near a player), and ws.message.send --recipient tag:team:red reaches only them. --tag adds (repeatable); --untag removes (repeatable), and one ending in * removes every tag with that prefix (--untag "cell:*"; "*" removes all). Every --untag applies before every --tag, so --untag "cell:*" --tag cell:12:7 moves a session to a new cell and keeps its other tags. Give at least one of the two. A tag is 1–128 characters, no spaces or *. --room (an exact room) and --session default to the room and the session of the trigger.room that started the run — tag on $connect. The changed view goes out with the room's next send (at once; in a tick room, after the tick). A held session keeps its tags. An exact room that is not open is FW_NODE_WS_ROOM_NOT_OPEN. Adds session: { session_id, tags } (all its tags now, sorted) and keeps the rest of the payload.

Flags

  • --room: The exact room; default: the room of the trigger.room that started the run.
  • --session: The session (its id); default: the session of the trigger.room that started the run.
  • --tag: A tag to add: team:red, seat:2, cell:12:7 (repeat for several).
  • --untag: A tag to remove, or a prefix ending in * (cell:*; * for all), applied before every --tag (repeat for several).

Examples

Put a joining player on a team

| ws.session.tag --tag "team:{{ input.room.auth.team }}"

After trigger.room --room "match-:id" --event $connect; ws.state.put --visible-to team:red now reaches this session.

It answers:

json
{  "session": {    "session_id": "ws-1f0c",    "tags": [      "team:red"    ]  }}

Move a player to the cells around it

| ws.session.tag --session ws-1f0c --untag "cell:*" --tag cell:12:7 --tag cell:12:8

Its old cells go, team:red stays: each entity written --visible-to cell:… now reaches it only near.

It answers:

json
{  "session": {    "session_id": "ws-1f0c",    "tags": [      "cell:12:7",      "cell:12:8",      "team:red"    ]  }}