Skip to content

Instantly share code, notes, and snippets.

@scaryTollens
Created November 8, 2019 22:23
Show Gist options
  • Save scaryTollens/85ee095ba3c10f71beea04bd9c1d2af4 to your computer and use it in GitHub Desktop.
Save scaryTollens/85ee095ba3c10f71beea04bd9c1d2af4 to your computer and use it in GitHub Desktop.
How to connect to a CoWorkr DDP Stream using DDPClient.py
from DDPClient import DDPClient
import hashlib
def cb(err, data):
print err
print data
m = hashlib.sha256()
m.update('secret123'.encode('utf-8'))
digest = m.hexdigest()
client = DDPClient('wss://testing.coworkr.co/websocket', auto_reconnect=True)
args = {
'user': {'email': '[email protected]'},
'password': {
'digest': digest,
'algorithm': 'sha-256'
}
}
def connected():
print '* CONNECTED'
client.on('connected', connected)
def changed(collection, id, fields, cleared):
print '* CHANGED {} {}'.format(collection, id)
for key, value in fields.items():
print ' - FIELD {} {}'.format(key, value)
for key, value in cleared.items():
print ' - CLEARED {} {}'.format(key, value)
client.on('changed', changed)
client.connect()
client.call('login', [args], cb)
sub_id = client.subscribe('workPointStatus', [], cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment