This library handles the connections and subscriptions and monitors the connection. It removes the underlaying websocket layer.
$ sudo pip3 install ActionCableZwei
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()
from actioncable.subscription import Subscription
subscription = 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()
from actioncable.message import Message
message = Message(action='update_something', data={'something': 'important'})
subscription.send(message)
subscription.remove()
connection.disconnect()
Pull it up!
Ask a question on StackOverflow with the tag 'actioncable-zwei'.
- To test the package.
Also here we would be thankful for pull requests.
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-explaining
Copyright (c) 2017 Tobias Feistmantl, MIT license