Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 7299676

Browse files
committed
Merge remote-tracking branch 'orig/master'
2 parents 5c2b318 + 5453baa commit 7299676

File tree

11 files changed

+32
-24
lines changed

11 files changed

+32
-24
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Python Client Library to interface with the Phoenix Realtime Server
66

77
## Installation
88
```bash
9-
pip3 install realtime_py==0.1.1a0
9+
pip3 install realtime==0.1.1a0
1010
```
1111

1212
## Installation from source
@@ -18,7 +18,7 @@ python3 usage.py
1818

1919
## Quick Start
2020
```python
21-
from realtime_py.connection import Socket
21+
from realtime.connection import Socket
2222

2323
def callback1(payload):
2424
print("Callback 1: ", payload)
@@ -47,7 +47,7 @@ if __name__ == "__main__":
4747
Here's how you could connect to your realtime endpoint using Supabase endpoint. Correct as of 5th June 2021. Please replace `SUPABASE_ID` and `API_KEY` with your own `SUPABASE_ID` and `API_KEY`. The variables shown below are fake and they will not work if you try to run the snippet.
4848

4949
```python
50-
from realtime_py.connection import Socket
50+
from realtime.connection import Socket
5151

5252
SUPABASE_ID = "dlzlllxhaakqdmaapvji"
5353
API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MT"

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
2-
name = "realtime-py"
3-
version = "0.1.3"
2+
name = "realtime"
3+
version = "0.0.3"
44
description = ""
55
authors = ["None"]
66

realtime/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__version__ = "0.0.3"
2+
3+
from realtime.channel import CallbackListener, Channel
4+
from realtime.connection import Socket
5+
from realtime.exceptions import NotConnectedError
6+
from realtime.message import *
7+
from realtime.transformers import *

realtime_py/channel.py renamed to realtime/channel.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import List, TYPE_CHECKING
77

88
if TYPE_CHECKING:
9-
from realtime_py.connection import Socket
9+
from realtime.connection import Socket
1010

1111
"""
1212
Callback Listener is a tuple with `event` and `callback`
@@ -49,7 +49,8 @@ async def _join(self) -> None:
4949
Coroutine that attempts to join Phoenix Realtime server via a certain topic
5050
:return: None
5151
"""
52-
join_req = dict(topic=self.topic, event="phx_join", payload={}, ref=None)
52+
join_req = dict(topic=self.topic, event="phx_join",
53+
payload={}, ref=None)
5354

5455
try:
5556
await self.socket.ws_connection.send(json.dumps(join_req))
@@ -74,4 +75,5 @@ def off(self, event: str) -> None:
7475
:param event: Stop responding to a certain event
7576
:return: None
7677
"""
77-
self.listeners = [callback for callback in self.listeners if callback.event != event]
78+
self.listeners = [
79+
callback for callback in self.listeners if callback.event != event]

realtime_py/connection.py renamed to realtime/connection.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
import websockets
99

10-
from realtime_py.channel import Channel
11-
from realtime_py.exceptions import NotConnectedError
12-
from realtime_py.message import HEARTBEAT_PAYLOAD, PHOENIX_CHANNEL, ChannelEvents, Message
10+
from realtime.channel import Channel
11+
from realtime.exceptions import NotConnectedError
12+
from realtime.message import HEARTBEAT_PAYLOAD, PHOENIX_CHANNEL, ChannelEvents, Message
1313

14-
logging.basicConfig(format="%(asctime)s:%(levelname)s - %(message)s", level=logging.INFO)
14+
logging.basicConfig(
15+
format="%(asctime)s:%(levelname)s - %(message)s", level=logging.INFO)
1516

1617

1718
def ensure_connection(func: Callable):
@@ -24,6 +25,7 @@ def wrapper(*args: Any, **kwargs: Any):
2425

2526
return wrapper
2627

28+
2729
class Socket:
2830
def __init__(self, url: str, params: dict = {}, hb_interval: int = 5) -> None:
2931
"""
@@ -50,7 +52,8 @@ def listen(self) -> None:
5052
:return: None
5153
"""
5254
loop = asyncio.get_event_loop() # TODO: replace with get_running_loop
53-
loop.run_until_complete(asyncio.gather(self._listen(), self._keep_alive()))
55+
loop.run_until_complete(asyncio.gather(
56+
self._listen(), self._keep_alive()))
5457

5558
async def _listen(self) -> None:
5659
"""
@@ -129,4 +132,5 @@ def summary(self) -> None:
129132
"""
130133
for topic, chans in self.channels.items():
131134
for chan in chans:
132-
print(f"Topic: {topic} | Events: {[e for e, _ in chan.callbacks]}]")
135+
print(
136+
f"Topic: {topic} | Events: {[e for e, _ in chan.callbacks]}]")
File renamed without changes.
File renamed without changes.
File renamed without changes.

realtime_py/.__init__.py.un~

-2.23 KB
Binary file not shown.

realtime_py/__init__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)