forked from named-data/PyCCN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receiving.py
41 lines (31 loc) · 808 Bytes
/
receiving.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pyccn
from subprocess import Popen, PIPE
import threading
import sys
def arrgh(x):
if sys.version_info.major >= 3:
return bytes(x, "ascii")
else:
return bytes(x)
class sendMessage(threading.Thread):
def run(self):
po = Popen(['ccnput', '-x', '5', '-t', 'ENCR', 'ccnx:/messages/hello'], stdin=PIPE)
po.communicate(arrgh("Hello everyone"))
# po.stdin.close()
po.wait()
thread = sendMessage()
name = pyccn.Name("ccnx:/messages/hello")
handle = pyccn.CCN()
thread.start()
co = handle.get(name)
thread.join()
print(co)
print(co.content)
print(type(co.content))
assert co.content == bytearray(b"Hello everyone")
print(co.name)
assert str(co.name) == "/messages/hello"
signedinfo = co.signedInfo
assert signedinfo.type == pyccn.CONTENT_ENCR
signature = co.signature
print(signedinfo)