ActionCable Client for Python 3
Project description
ActionCable Client - A Python 3 client for Rails' Action Cable
This library handles the connections and subscriptions and monitors the connection. It removes the underlaying websocket layer.
Currently authentication is not managed by this library.
Credits
The project originate this that was stalled for more than 5 years.
ROADMAP
See Roadmap file
Get started
sudo pip3 install actioncable_client
Example usage
Setup the connection
Setup the connection to your Action Cable server.
from actioncable.connection import Connection
connection = Connection(url='wss://url_to_your_cable_server/cable', origin='https://url_to_your_cable_server')
connection.connect()
Subscribe to a channel
from actioncable.subscription import Subscription
subscription = Subscription(connection, identifier={'channel': 'YourChannelCLassName'})
def on_receive(message: dict):
print('New message arrived!')
print('Action: {} | Data: {}'.format(message['action'], message['data']))
subscription.on_receive(callback=on_receive)
subscription.create()
Send data
from actioncable.message import Message
message = Message(action='update_something', data={'something': 'important'})
subscription.send(message)
Unsubscribe
subscription.remove()
Close connection
connection.disconnect()
Development
Pull it up!
You need help?
Ask a question on StackOverflow with the tag 'actioncable-client'.
Contribution
Create pull requests on GitLab and help us to improve this package. There are some guidelines to follow:
- Follow the conventions
- Test all your implementations
- Document methods which aren't self-explaining
- try to follow the Roadmap
Copyright (c) 2024 Liant SASU, MIT license
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file actioncable_client-0.3.1.dev0.tar.gz
.
File metadata
- Download URL: actioncable_client-0.3.1.dev0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15906bf6e3903191a5f0dc3124f2533487a4f4dcdafc70dcc9cea3c76c217c63 |
|
MD5 | 4e2e7d00038ec26fba17ff04f4c84794 |
|
BLAKE2b-256 | 7ab3f1b2ad15f04a7a66a1823915adf3da0b3fae6b738bac699c4826d68b50aa |
File details
Details for the file actioncable_client-0.3.1.dev0-py3-none-any.whl
.
File metadata
- Download URL: actioncable_client-0.3.1.dev0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b52223afba13634d5660cb8a2b45892007f6f235fb3e2e9f1882e76125db7ba9 |
|
MD5 | c5978e64303970a79463d216950df620 |
|
BLAKE2b-256 | a504273c67675ba02cdf0591f18f1e14a42c3bf2756fdf19d76a402ba24e2195 |