Commit 78a5539b authored by Tony's avatar Tony
Browse files

Fixing bugs

parent 71fef9a8
......@@ -113,7 +113,7 @@ def join():
print(server.find().count())
for serv in decoded['value']:
if (str(serv['ip']) == '0.0.0.0' or str(serv['ip']) == '127.0.0.1'):
print("Kocak")
print("Invalid IP")
else:
server.insert({"ip": str(serv['ip']), "port": serv['port']}) #Insert to database
elif (decoded['status'] == "error"): #join failed
......@@ -418,7 +418,7 @@ def clientThread(conn):
upsert = True
)
elif (res['status'] == 'error'): #sendfind error
else: #sendfind error
print("Error response from server "+ str(serve['ip']) + ":" + str(serve['port']))
sock_serv.close()
......@@ -528,15 +528,18 @@ def clientThread(conn):
loadingOK = False
if (loadingOK):
print("LOADING OK")
#Accept Status OK
if (res['status'] == "OK"):
if (res['status'] == "ok"):
#Update database
user.update({'_id': ObjectId(decoded['token'])},{"$inc": {'inventory.'+str(marketOff['demanded_item']): -marketOff['n_demanded_item'],
'inventory.'+str(marketOff['offered_item']): marketOff['n_offered_item']}})
market.remove({'offer_token': marketOff['offer_token']})
reply = {"status": "ok"}
elif (res['status'] == "fail"):
reply = {"status": "fail", "description": "offer is already taken"}
else:
reply = {"status": "error"}
#closing socket
sock_serv.close()
......@@ -569,8 +572,6 @@ def clientThread(conn):
else: #offer already taken
reply = {"status": "fail", "description": "offer is already taken"}
print("AYAM")
print(str(reply))
sendAccept = True
#Accept(server)
......@@ -595,7 +596,6 @@ def clientThread(conn):
print("response: " + str(reply))
conn.sendall(bytes(json.dumps(reply), 'UTF-8'))
print("LEWAT A")
accept = True
break
......
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