aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/realtime/_sync
diff options
context:
space:
mode:
Diffstat (limited to '.venv/lib/python3.12/site-packages/realtime/_sync')
-rw-r--r--.venv/lib/python3.12/site-packages/realtime/_sync/__init__.py0
-rw-r--r--.venv/lib/python3.12/site-packages/realtime/_sync/channel.py30
-rw-r--r--.venv/lib/python3.12/site-packages/realtime/_sync/client.py71
-rw-r--r--.venv/lib/python3.12/site-packages/realtime/_sync/presence.py12
4 files changed, 113 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/realtime/_sync/__init__.py b/.venv/lib/python3.12/site-packages/realtime/_sync/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/realtime/_sync/__init__.py
diff --git a/.venv/lib/python3.12/site-packages/realtime/_sync/channel.py b/.venv/lib/python3.12/site-packages/realtime/_sync/channel.py
new file mode 100644
index 00000000..3512f9b7
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/realtime/_sync/channel.py
@@ -0,0 +1,30 @@
+from __future__ import annotations
+
+from typing import TYPE_CHECKING, Optional
+
+from realtime.types import RealtimeChannelOptions
+
+if TYPE_CHECKING:
+ from .client import SyncRealtimeClient
+
+
+class SyncRealtimeChannel:
+ """
+ `Channel` is an abstraction for a topic listener for an existing socket connection.
+ Each Channel has its own topic and a list of event-callbacks that responds to messages.
+ Should only be instantiated through `connection.RealtimeClient().channel(topic)`.
+ """
+
+ def __init__(
+ self,
+ socket: SyncRealtimeClient,
+ topic: str,
+ params: Optional[RealtimeChannelOptions] = None,
+ ) -> None:
+ """
+ Initialize the Channel object.
+
+ :param socket: RealtimeClient object
+ :param topic: Topic that it subscribes to on the realtime server
+ :param params: Optional parameters for connection.
+ """
diff --git a/.venv/lib/python3.12/site-packages/realtime/_sync/client.py b/.venv/lib/python3.12/site-packages/realtime/_sync/client.py
new file mode 100644
index 00000000..634a5343
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/realtime/_sync/client.py
@@ -0,0 +1,71 @@
+from typing import Any, Dict, List, Optional
+
+from .channel import RealtimeChannelOptions, SyncRealtimeChannel
+
+NOT_IMPLEMENTED_MESSAGE = "This feature isn't available in the sync client. You can use the realtime feature in the async client only."
+
+
+class SyncRealtimeClient:
+ def __init__(
+ self,
+ url: str,
+ token: str,
+ auto_reconnect: bool = True,
+ params: Optional[Dict[str, Any]] = None,
+ hb_interval: int = 30,
+ max_retries: int = 5,
+ initial_backoff: float = 1.0,
+ ) -> None:
+ """
+ Initialize a RealtimeClient instance for WebSocket communication.
+
+ :param url: WebSocket URL of the Realtime server. Starts with `ws://` or `wss://`.
+ Also accepts default Supabase URL: `http://` or `https://`.
+ :param token: Authentication token for the WebSocket connection.
+ :param auto_reconnect: If True, automatically attempt to reconnect on disconnection. Defaults to False.
+ :param params: Optional parameters for the connection. Defaults to an empty dictionary.
+ :param hb_interval: Interval (in seconds) for sending heartbeat messages to keep the connection alive. Defaults to 30.
+ :param max_retries: Maximum number of reconnection attempts. Defaults to 5.
+ :param initial_backoff: Initial backoff time (in seconds) for reconnection attempts. Defaults to 1.0.
+ """
+
+ def channel(
+ self, topic: str, params: Optional[RealtimeChannelOptions] = None
+ ) -> SyncRealtimeChannel:
+ """
+ :param topic: Initializes a channel and creates a two-way association with the socket
+ :return: Channel
+ """
+ raise NotImplementedError(NOT_IMPLEMENTED_MESSAGE)
+
+ def get_channels(self) -> List[SyncRealtimeChannel]:
+ raise NotImplementedError(NOT_IMPLEMENTED_MESSAGE)
+
+ def remove_channel(self, channel: SyncRealtimeChannel) -> None:
+ """
+ Unsubscribes and removes a channel from the socket
+ :param channel: Channel to remove
+ :return: None
+ """
+ raise NotImplementedError(NOT_IMPLEMENTED_MESSAGE)
+
+ def remove_all_channels(self) -> None:
+ """
+ Unsubscribes and removes all channels from the socket
+ :return: None
+ """
+ raise NotImplementedError(NOT_IMPLEMENTED_MESSAGE)
+
+ def set_auth(self, token: Optional[str]) -> None:
+ """
+ Set the authentication token for the connection and update all joined channels.
+
+ This method updates the access token for the current connection and sends the new token
+ to all joined channels. This is useful for refreshing authentication or changing users.
+
+ Args:
+ token (Optional[str]): The new authentication token. Can be None to remove authentication.
+
+ Returns:
+ None
+ """
diff --git a/.venv/lib/python3.12/site-packages/realtime/_sync/presence.py b/.venv/lib/python3.12/site-packages/realtime/_sync/presence.py
new file mode 100644
index 00000000..db02a1ce
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/realtime/_sync/presence.py
@@ -0,0 +1,12 @@
+"""
+ Defines the RealtimePresence class and its dependencies.
+"""
+
+from typing import Optional
+
+from ..types import PresenceOpts
+
+
+class SyncRealtimePresence:
+ def __init__(self, channel, opts: Optional[PresenceOpts] = None):
+ pass