2015-02-11 09:18:31 +00:00
|
|
|
from __future__ import print_function
|
2015-02-15 01:48:38 +00:00
|
|
|
import time, json
|
2015-02-15 02:45:29 +00:00
|
|
|
from wormhole.transcribe import Receiver, list_channels
|
2015-02-15 01:48:38 +00:00
|
|
|
from wormhole.codes import input_code_with_completion
|
2015-02-11 00:50:32 +00:00
|
|
|
|
|
|
|
APPID = "lothar.com/wormhole/text-xfer"
|
|
|
|
|
|
|
|
# we're receiving
|
2015-02-15 02:45:29 +00:00
|
|
|
channel_ids = list_channels()
|
|
|
|
code = input_code_with_completion("Enter receive-text wormhole code: ",
|
|
|
|
channel_ids)
|
2015-02-11 09:45:54 +00:00
|
|
|
start = time.time()
|
2015-02-11 10:09:26 +00:00
|
|
|
data = json.dumps({"message": "ok"}).encode("utf-8")
|
|
|
|
r = Receiver(APPID, data, code)
|
2015-02-11 02:34:13 +00:00
|
|
|
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))
|