Skip to content

dazzl-tv/python-actioncable-zwei

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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={'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

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-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-explaining

Copyright (c) 2017 Tobias Feistmantl, MIT license

About

Action Cable Client for Python 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%