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]

pip install socketIO-client

Example[edit]

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

def on_connect():

   print('connect')

def on_disconnect():

   print('disconnect')

def on_reconnect():

   print('reconnect')

def on_mqtt(*args):

   #print('on_mqtt', args)
   call = json.loads(args[0]['payload'])
   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>