You do not have permission to edit this page, for the following reason:

The action you have requested is limited to users in the group: Users.


You can view and copy the source of this page.

Return to Code Examples/LastHeard/Python.

Requirements[edit]

  1. pip install socketIO-client

Example[edit]

<syntaxhighlight lang="python"> from socketIO_client import SocketIO import json

def on_connect():

  1. print('connect')

def on_disconnect():

  1. print('disconnect')

def on_reconnect():

  1. print('reconnect')

def on_mqtt(*args):

  1. #print('on_mqtt', args)
  2. call = json.loads(args[0]['payload'])
  3. print json.dumps(call,separators=(',',':'),sort_keys=True,indent=4)

socket = SocketIO('https://api.brandmeister.network/lh') socket.on('connect', on_connect) socket.on('disconnect', on_disconnect) socket.on('reconnect', on_reconnect) socket.on('mqtt', on_mqtt) socket.wait() </syntaxhighlight>