Last active
August 29, 2015 14:26
-
-
Save justinplatz/f9b5d72b00ae2b9518fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Kill PubNub subscription thread | |
| def _kill(m, n): | |
| pubnub.unsubscribe(subchannel) | |
| # ==============================Define Main================================== | |
| def main(): | |
| print("Starting Main") | |
| pubnub = Pubnub(publish_key = 'demo', | |
| subscribe_key = 'demo', | |
| uuid = "pi") | |
| channel = 'my_channel' | |
| def _callback(m,n): | |
| # ==============================Left Hand============================== | |
| left_hand = m.get("left_hand",{}) | |
| if left_hand != {}: | |
| handleLeft(left_hand) | |
| # ==============================Right Hand============================= | |
| right_hand = m.get("right_hand",{}) | |
| if right_hand != {}: | |
| handleRight(right_hand) | |
| #Catch and Print Error | |
| def _error(m): | |
| print(m) | |
| #Subscribe to subchannel, set callback function to _callback and set error fucntion to _error | |
| pubnub.subscribe(channels=channel, callback=_callback, error=_error, connect=_error) | |
| # ==============================Call Main==================================== | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment