magic-wormhole/bin/receive_text.py

16 lines
437 B
Python
Raw Normal View History

2015-02-11 09:18:31 +00:00
from __future__ import print_function
2015-02-11 09:45:54 +00:00
import time, sys, json
2015-02-11 09:18:31 +00:00
from wormhole.transcribe import Receiver
2015-02-11 00:50:32 +00:00
APPID = "lothar.com/wormhole/text-xfer"
# we're receiving
2015-02-11 09:45:54 +00:00
start = time.time()
2015-02-11 00:50:32 +00:00
code = sys.argv[1]
data = json.dumps({"message": "ok"}).encode("utf-8")
r = Receiver(APPID, data, code)
them_bytes = r.get_data()
2015-02-11 00:50:32 +00:00
them_d = json.loads(them_bytes.decode("utf-8"))
print(them_d["message"])
2015-02-11 09:45:54 +00:00
print("elapsed time: %.2f" % (time.time() - start))