You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks so much for this library! I've got it streaming the information (for quoinex.com) to the screen using one of your examples, via both logging and print.
However, I'm finding that logging provides more information than print at the moment - logging includes event and channel. Is there a way to access these bits of information outside of logging?
The problem I have is that if I subscribe to lots of channels, I'm not sure how I'll identify which response belongs to which channel. An ugly workaround below is to create a callback function for each subscription, but I assume there is a far more elegant way.
Any help would be appreciated please!
importpysherimportsysimporttime# Add a logging handler so we can see the raw communication dataimportloggingroot=logging.getLogger()
root.setLevel(logging.INFO)
ch=logging.StreamHandler(sys.stdout)
root.addHandler(ch)
pusher=pysher.Pusher('XXXX') #key removeddefchannel_callbacksell(message):
response="btcjpy_sell: %s"%messageprint(response)
defchannel_callbackbuy(message):
response="btcjpy_buy: %s"%messageprint(response)
defconnect_handler(data):
channelsell=pusher.subscribe('price_ladders_cash_btcjpy_sell')
channelsell.bind('updated', channel_callbacksell)
channelbuy=pusher.subscribe('price_ladders_cash_btcjpy_buy')
channelbuy.bind('updated', channel_callbackbuy)
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()
whileTrue:
time.sleep(1)
Got this working by taking another look at your example. Solved it by passing the following keyword: channel=channel.__dict__['name']
importsysimporttimeimportpysher# Add a logging handler so we can see the raw communication dataimportloggingroot=logging.getLogger()
root.setLevel(logging.INFO)
ch=logging.StreamHandler(sys.stdout)
root.addHandler(ch)
pusher=pysher.Pusher(appkey)
defmy_func(*args, **kwargs):
print("processing Args:", args)
print("processing Kwargs:", kwargs)
defconnect_handler(data):
channel=pusher.subscribe('mychannel')
channel.bind('myevent', my_func, channel=channel.__dict__['name'], event='updated')
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()
whileTrue:
time.sleep(1)
Thanks so much for this library! I've got it streaming the information (for quoinex.com) to the screen using one of your examples, via both
logging
andprint
.However, I'm finding that logging provides more information than print at the moment - logging includes
event
andchannel
. Is there a way to access these bits of information outside of logging?The problem I have is that if I subscribe to lots of channels, I'm not sure how I'll identify which response belongs to which channel. An ugly workaround below is to create a callback function for each subscription, but I assume there is a far more elegant way.
Any help would be appreciated please!
The results I get to screen are:
Logging Output (with 'event' and 'channel'):
Print Output (with just 'data'):
The text was updated successfully, but these errors were encountered: