pyssb/test_client.py

29 lines
585 B
Python
Raw Normal View History

import os
2017-05-25 10:47:01 +00:00
from asyncio import get_event_loop
from base64 import b64decode
import yaml
from nacl.signing import SigningKey
2017-05-25 10:47:01 +00:00
from ssb.packet_stream import PSClient
with open(os.path.expanduser('~/.ssb/secret')) as f:
config = yaml.load(f)
server_pub_key = b64decode(config['public'][:-8])
2017-05-25 10:47:01 +00:00
async def main(loop):
async for msg in packet_stream:
2017-05-25 10:47:01 +00:00
print(msg)
print('bye')
loop = get_event_loop()
packet_stream = PSClient('127.0.0.1', 8008, SigningKey.generate(), server_pub_key, loop=loop)
packet_stream.connect()
2017-05-25 10:47:01 +00:00
loop.run_until_complete(main(loop))
loop.close()