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',
|
2015-08-06 20:44:37 +00:00
|
|
|
'max_connections': 10
|
2015-08-06 19:08:22 +00:00
|
|
|
},
|
|
|
|
'ws-mqtt': {
|
|
|
|
'bind': '127.0.0.1:8080',
|
|
|
|
'type': 'ws'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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__':
|
|
|
|
formatter = "[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
|
|
|
|
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()
|