Skip to content

Commit

Permalink
pip pkg related refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lionellloh committed Sep 30, 2020
1 parent 4949494 commit adef018
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions realtime_py/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from realtime_py.channel import CallbackListener, Channel
from realtime_py.connection import Socket
from realtime_py.exceptions import NotConnectedError
from realtime_py.message import *
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'Programming Language :: Python :: 3.8',
],
description="Python Client for Phoenix Channels",
download_url="https://github.com/lionellloh/realtime-py/archive/0.1.0-alpha.tar.gz",
install_requires=requirements,
license="MIT license",
long_description=readme + '\n\n' + history,
Expand Down
17 changes: 9 additions & 8 deletions usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ def callback1(payload):
def callback2(payload):
print("Callback 2: ", payload)

URL = "ws://localhost:4000/socket/websocket"
s = Socket(URL)
s.connect()
if __name__ == "__main__":
URL = "ws://localhost:4000/socket/websocket"
s = Socket(URL)
s.connect()

channel_1 = s.set_channel("realtime:public:todos")
channel_1.join().on("UPDATE", callback1)
channel_1 = s.set_channel("realtime:public:todos")
channel_1.join().on("UPDATE", callback1)

channel_2 = s.set_channel("realtime:public:users")
channel_2.join().on("*", callback2)
channel_2 = s.set_channel("realtime:public:users")
channel_2.join().on("*", callback2)

s.listen()
s.listen()

0 comments on commit adef018

Please sign in to comment.