amqtt/samples/broker_start.py

37 wiersze
869 B
Python
Czysty Zwykły widok Historia

2015-07-07 20:48:53 +00:00
import logging
import asyncio
from hbmqtt.broker import Broker
logger = logging.getLogger(__name__)
2015-08-06 19:08:22 +00:00
config = {
'listeners': {
'default': {
'type': 'tcp'
},
'tcp-mqtt': {
'bind': '0.0.0.0:1883',
'max_connections': 10
2015-08-06 19:08:22 +00:00
},
'ws-mqtt': {
'bind': '127.0.0.1:8080',
'type': 'ws'
},
2015-08-08 11:57:48 +00:00
},
'sys_interval': 0,
2015-08-06 19:08:22 +00:00
}
broker = Broker(config)
2015-07-07 20:48:53 +00:00
@asyncio.coroutine
def test_coro():
yield from broker.start()
2015-07-10 20:55:43 +00:00
#yield from asyncio.sleep(5)
#yield from broker.shutdown()
2015-07-07 20:48:53 +00:00
if __name__ == '__main__':
2015-08-20 19:42:56 +00:00
formatter = "[%(asctime)s] %(name)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
2015-07-07 20:48:53 +00:00
logging.basicConfig(level=logging.DEBUG, format=formatter)
asyncio.get_event_loop().run_until_complete(test_coro())
2015-07-10 20:55:43 +00:00
asyncio.get_event_loop().run_forever()