res://addons/w4gd/supabase/realtime.gd:Subscription

Inherits: RefCounted

Represents a subscription or potential subscription to a realtime channel.

Properties

Dictionary

config

String

name

Methods

int

broadcast ( String p_event, Dictionary p_payload )

Dictionary

get_presence_state ( )

void

on_postgres_changes ( String p_event, String p_table, String p_filter )

int

send ( String p_type, String p_event, Variant p_payload, Variant p_ref, bool await_response )

int

subscribe ( )

void

track ( Dictionary p_data )

int

unsubscribe ( )

void

untrack ( )


Signals

deleted ( Variant p_data )

Emitted when data is deleted from one of the Postgres tables we are watching.


inserted ( Variant p_data )

Emitted when data is inserted to one of the Postgres tables we are watching.


received_broadcast ( Variant p_data )

Emitted when a broadcast message is received.


received_presence ( Variant p_event, Variant p_data )

Emitted when presence data is received.


received_system_message ( Variant p_data )

Emitted when a system message is received.


subscribed ( )

Emitted after we've successfully subscribed.


unsubscribed ( )

Emitted after we've successfully unsubscribed.


updated ( Variant p_data )

Emitted when data is updated on one of the Postgres tables we are watching.


Property Descriptions

Dictionary config

Configuration passed to Supabase when subscribing.


String name

The name of the channel.


Method Descriptions

int broadcast ( String p_event, Dictionary p_payload )

Sends a broadcast message to all other users on this channel.


Dictionary get_presence_state ( )

Gets the current presence state on this channel.


void on_postgres_changes ( String p_event, String p_table, String p_filter )

Adds to the subscription configuration, requesting that we receive updates related to the given Postgres table. To have any effect, this must be called before subscribe. p_event should be one of: '*', 'INSERT', 'UPDATE', or 'DELETE' p_table will refer to a table on the 'public' schema, unless give a fully qualified table name (ex. 'schema.table_name'). p_filter is a special string specifying the column, operator and value to filter on. For example, 'body=eq.hey' will filter for rows where the 'body' column equals 'hey'. For more information, see the Supabase docs: https://supabase.com/docs/guides/realtime/postgres-changes#filter-changes


int send ( String p_type, String p_event, Variant p_payload, Variant p_ref, bool await_response )

Sends an arbitrary event on this channel. p_type must be one of 'broadcast' or 'presence'. p_event must be one of 'track' or 'untrack' when p_type is 'presence', or can be any arbitrary string when p_type is 'broadcast'.


int subscribe ( )

Subscribes to the channel.


void track ( Dictionary p_data )

Tracks the given data as the presence state for the current user on this channel.


int unsubscribe ( )

Unsubscribes from the channel.


void untrack ( )

Removes the presence state for the current user on this channel.