Commit 5490422f authored by mamat-rahmat's avatar mamat-rahmat
Browse files

hubungan sama server lain masih ngebug

parent 757b459a
......@@ -402,9 +402,6 @@ def handler(a, c):
response = str(dictResponse)
elif (method == "sendfind"):
## TODO : AMBIL DARI SEMUA SERVER, TAMBAH PENGECUALIAN DARI SENDIRI
token = dataJSON["token"]
item = dataJSON["item"]
kriteria1Object = {"offered_item" : item}
......@@ -520,8 +517,25 @@ def handler(a, c):
response = "{'status' : 'ok'}"
else:
kriteria2Object = {"offer_token" : offer_token}
response = "{'status' : 'fail', 'description' : 'not exists'}"
#kirim accept offer ke server lain
for server in listActiveServer:
if (server["ip"] != hostLaptop):
print(server["ip"], server["port"])
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((server["ip"],server["port"]))
message = '{ "method" : "accept", "offer_token" : "' + offer_token + '"}'
print(message)
s2.send(str.encode(message))
tm = s2.recv(4096)
tmString = tm.decode("utf-8")
print(tmString)
tmJSON = json.JSONDecoder().decode(tmString)
if (tmJSON["status"] == "ok"):
response = "{'status' : 'ok'}"
else:
response = "{'status' : 'fail', 'description' : 'not exists'}"
elif (method == 'accept'):
offer_token = dataJSON['offer_token']
......
{
"name": "lima",
"width": 5,
"height": 5,
"map": [
[
4,
8,
4,
8,
6,
3,
5,
8
],
[
7,
4,
1,
6,
5,
9,
3
8,
9
],
[
2,
1,
8,
6,
0,
8,
5
7,
9
],
[
0,
7,
7,
6,
9,
7
1,
2
],
[
4,
8,
7,
1,
9,
5
5,
1
]
]
],
"name": "hihi",
"height": 5
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment