2017-06-04 22:27:44 +00:00
|
|
|
import os
|
2017-05-25 10:47:01 +00:00
|
|
|
from asyncio import get_event_loop
|
|
|
|
from base64 import b64decode
|
|
|
|
|
2017-06-04 22:27:44 +00:00
|
|
|
import yaml
|
|
|
|
from nacl.signing import SigningKey
|
|
|
|
|
2017-05-25 10:47:01 +00:00
|
|
|
from ssb.packet_stream import PSClient
|
|
|
|
|
2017-06-04 22:27:44 +00:00
|
|
|
|
|
|
|
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):
|
2017-06-04 22:27:44 +00:00
|
|
|
async for msg in packet_stream:
|
2017-05-25 10:47:01 +00:00
|
|
|
print(msg)
|
|
|
|
print('bye')
|
|
|
|
|
|
|
|
loop = get_event_loop()
|
2017-06-04 22:27:44 +00:00
|
|
|
|
|
|
|
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()
|