Commit 027c2d3d authored by Muhammad Yafi's avatar Muhammad Yafi
Browse files

add send accept

parent 692f5fc1
......@@ -326,16 +326,23 @@ class ConnectionHandler:
Market.accept(offer_token)
# ini bagian yafi
# call accept
(socket,host,port) = (Socket.socket(), offer.ip, offer.port)
socket.settimeout(SocketIO.SERVER_CONNECTION_TIMEOUT)
try :
socket.connect((host,port))
except Exception as msg:
print(msg)
socketio = SocketIO(socket)
socketio.write_to_socket(json.dumps({'method':'accept','offer_token':offer.token}).encode('ascii'))
target_data = socketio.read_from_socket()
self._socketio.write_to_socket(target_data)
data = json.dumps({'status': 'ok'})
else:
data = json.dumps({'status': 'fail', 'description': 'offer is not available'})
try:
self._socketio.write_to_socket(data.encode('ascii'))
except Exception as msg:
print(msg)
# invoke map
def handle_fetchitem(self,token,offer_token):
......
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