Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0x7466/python-actioncable-zwei
Action Cable Client for Python 3
https://github.com/0x7466/python-actioncable-zwei
actioncable client-side python3 rails real-time websocket
Last synced: 3 months ago
JSON representation
Action Cable Client for Python 3
- Host: GitHub
- URL: https://github.com/0x7466/python-actioncable-zwei
- Owner: 0x7466
- License: mit
- Created: 2017-04-02T17:39:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-10T11:04:58.000Z (8 months ago)
- Last Synced: 2024-10-05T11:45:13.464Z (3 months ago)
- Topics: actioncable, client-side, python3, rails, real-time, websocket
- Language: Python
- Size: 22.5 KB
- Stars: 15
- Watchers: 3
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActionCableZwei - 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.
## Get started
```
$ sudo pip3 install ActionCableZwei
```## Example usage
### Setup the connection
Setup the connection to your Action Cable server.```python
from actioncable.connection import Connectionconnection = Connection(url='wss://url_to_your_cable_server/cable', origin='https://url_to_your_cable_server')
connection.connect()
```### Subscribe to a channel
```python
from actioncable.subscription import Subscriptionsubscription = Subscription(connection, identifier={'identifier': 'AppChannel'})
def on_receive(message):
print('New message arrived!')
print('Action: {} | Data: {}'.format(message.action, message.data))subscription.on_receive(callback=on_receive)
subscription.create()
```### Send data
```python
from actioncable.message import Messagemessage = Message(action='update_something', data={'something': 'important'})
subscription.send(message)
```### Unsubscribe
```python
subscription.remove()
```### Close connection
```python
connection.disconnect()
```## Development
Pull it up!
## You need help?
Ask a question on [StackOverflow](https://stackoverflow.com/) with the tag 'actioncable-zwei'.
## Things to do
* **To test the package.**
Also here we would be thankful for pull requests.
## Contribution
Create pull requests on Github and help us to improve this gem. There are some guidelines to follow:
* Follow the conventions
* Test all your implementations
* Document methods which aren't self-explainingCopyright (c) 2017 Tobias Feistmantl, MIT license