def onCancel(data): print 'On was canceled' def onComplete(data): print 'Set was completed', data #flame.auth( AUTH_KEY ) # Push only works on Unix boxes, need to fix _get_push_id to work cross platform #sms.push("Push test") flame.on('child_added', on_child_added, onCancel) flame.once('child_added', on_child_added) flame.on('child_removed', on_child_removed ) flame.child('dat').on('value', on_value_read) flame.child('online').set(True, onComplete) flame.child('online').setPriority(100) flame.child('online').onDisconnect().set(False) flame.child("test").on('child_added', on_child_added) flame.child("test").on('value', on_value_read) flame.child('dat').update({'broom': 'bristle'}) flame.child("test").off('value') # Querying half works, when your supply a query with a larger scope (ie a "value" bind to a parent) # it breaks because we're not filtering incoming results. #sms.startAt(None, '-Ip_SsFU5LY_63gH07x2').limit(3).on('child_added', say_body) flame.child('-Ip_SxEZ-ZG7Q1yfPiuf').on('value', on_value_read_specific) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully flame.waitForInterrupt()
return # print msgData.val()['name'] + ": " + msg print msgData.val() if msg == u'left': PressKey(ord('A')) elif msg == u'right': PressKey(ord('D')) elif msg == u'up': PressKey(ord('W')) elif msg == u'down': PressKey(ord('S')) elif msg == u'a': # PressKey(0x41) # a key PressKey(ord('Z')) # z key elif msg == u'b': # PressKey(0x42) # b key PressKey(ord('X')) # x key elif msg == u'select': PressKey(ord('B')) elif msg == u'start': PressKey(ord('N')) numUsers = 0 #while True: msglist = Firebase('https://amber-fire-9230.firebaseio.com/msg') #msglist.child('msg').on('child_added', onMsgReceive) loadingTime = long(time.time() * 1000) msglist.limit(40).on('child_added', onMsgReceive) msglist.waitForInterrupt() # time.sleep(10)
def on_value_read(snapshot): print str(snapshot.name()) + str(snapshot.val()) + ' < value of test ' def on_child_changed(snapshot): print str(snapshot.name()) + ' < child_changed in /test_child_changed/' def on_child_added_once(snapshot): print str(snapshot.name()) + ' < child_added once!' def on_value_read_specific(snapshot): print snapshot.val(), "<specific" def onCancel(data): print 'On was canceled' def onComplete(data): print 'Set was completed', data server.child("ask").on('value', on_value_read) server.child("bid").on('value', on_value_read) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully server.waitForInterrupt()
print(str(snapshot.val()) + ' < child_removed from /test_child_removed/') def on_child_added(snapshot): print(str(snapshot.name()) + ' < child_added to /test_child_added/') def on_value_read(snapshot): print(str(snapshot.name()) + str(snapshot.val()) + ' < value of test ') def on_child_changed (snapshot): print(str(snapshot.name()) + ' < child_changed in /test_child_changed/') def on_child_added_once (snapshot): print(str(snapshot.name()) + ' < child_added once!') def on_value_read_specific(snapshot): print(snapshot.val(), "<specific") def onCancel(data): print('On was canceled') def onComplete(data): print('Set was completed', data) server.child("ask").on('value', on_value_read) server.child("bid").on('value', on_value_read) # This is important to interupt the threaded socket when a # keyboard interupt is received, it allows us to shut down gracefully server.waitForInterrupt()
# print msgData.val()['name'] + ": " + msg print msgData.val() if msg == u'left': PressKey(ord('A')) elif msg == u'right': PressKey(ord('D')) elif msg == u'up': PressKey(ord('W')) elif msg == u'down': PressKey(ord('S')) elif msg == u'a': # PressKey(0x41) # a key PressKey(ord('Z')) # z key elif msg == u'b': # PressKey(0x42) # b key PressKey(ord('X')) # x key elif msg == u'select': PressKey(ord('B')) elif msg == u'start': PressKey(ord('N')) numUsers = 0 #while True: msglist = Firebase('https://amber-fire-9230.firebaseio.com/msg') #msglist.child('msg').on('child_added', onMsgReceive) loadingTime = long(time.time() * 1000) msglist.limit(40).on('child_added', onMsgReceive) msglist.waitForInterrupt() # time.sleep(10)