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