-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnector.py
More file actions
128 lines (79 loc) · 3.07 KB
/
Connector.py
File metadata and controls
128 lines (79 loc) · 3.07 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# from abc import ABC, abstractmethod
# import signalslot
# from Receiver import *
# nodedictionary = {} # Dictionary to store nodes into slots -> {"IPORT": IP n PORT, "Slot"}
# destinationdict = {} #
# class NetworkInterface(ABC):
# @abstractmethod
# def connect(self):
# pass
# @abstractmethod
# def send(self):
# pass
# @abstractmethod
# def receive(self):
# pass
# class RealNetwork(NetworkInterface):
# def connect(self, sender_ip, sender_port, destination_ip, destination_port):
# pass
# def send(self):
# # connect to something for real
# return
# def receive(self):
# # transfer a bunch of data
# return
# class FakeSocket(object):
# def __init__(self, fakeip, fakeport, payload):
# # SenderIP (signal), SenderPort
# self.fakeip = fakeip
# self.fakeport = fakeport
# self.payload = payload
# def connect(self, destination_ip, destination_port):
# self.destination_ip = destination_ip
# self.destination_port = destination_port
# nodeid = (self.fakeip, self.fakeport)
# destination = (destination_ip, destination_port)
# # Add signal/request to dictionary
# nodedictionary = {"nodesignal":[], "payload":[], "destination":[]}
# nodedictionary["nodesignal"].append(self.fakeip)
# nodedictionary["payload"].append(self.payload)
# nodedictionary["destination"].append(destination_ip)
# print(nodedictionary["nodesignal"])
# # Connect function to signal
# # self.n_conf.connect(yourmodule_conf)
# # lookup destination dictionary
# # pass
# def bind(self):
# print('\n*** This is binding process ***')
# # print
# m = self.nodedictionary["nodesignal"]
# if m == "node1":
# #note: add argument
# m1 = MatcherExample() #lookup node id
# m1.sender(self.destination_ip, self.destination_port)
# # # if self.nodedictionary["destination"] == "matcher one":
# # print("Send payload to matcher one")
# def listen(self):
# # print(m_conf)
# pass
# class FakeNetwork(NetworkInterface):
# def __init__(self,sender_ip, sender_port, destination_ip, destination_port, payload):
# # sender_ip = 127.0.0.1;
# self.sender_ip = sender_ip
# self.sender_port = sender_port
# self.destination_ip = destination_ip
# self.destination_port = destination_port
# self.payload = payload
# self.socket = FakeSocket(sender_ip, sender_port, payload)
# self.socket.connect(destination_ip, destination_port)
# # sender_ip()
# def connect(self):
# self.socket.connect(self.sender_ip, self.sender_port)
# def bind(self):
# self.socket.bind(self)
# def listen(self):
# self.socket.listen()
# def send(self, Request):
# return
# def receive(self):
# return