Skip to content
Snippets Groups Projects
Commit 8e19d9bc authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

destiny machine funfa

parent a28e6fb5
No related branches found
No related tags found
No related merge requests found
...@@ -140,8 +140,6 @@ def client (): ...@@ -140,8 +140,6 @@ def client ():
try: try:
global TOKEN global TOKEN
global HighPriority global HighPriority
udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest = (HOST, SEND_PORT)
protocolMessage = Protocol() protocolMessage = Protocol()
global queue global queue
queue = Queue.PriorityQueue() queue = Queue.PriorityQueue()
...@@ -158,7 +156,6 @@ def client (): ...@@ -158,7 +156,6 @@ def client ():
HighPriority = queue.queue[0] HighPriority = queue.queue[0]
threadServer._Thread__stop() threadServer._Thread__stop()
threadToken._Thread__stop() threadToken._Thread__stop()
udp.close()
except: except:
print 'OPS, ALGO OCORREU ERRADO' print 'OPS, ALGO OCORREU ERRADO'
threadServer._Thread__stop() threadServer._Thread__stop()
...@@ -169,20 +166,24 @@ def server (): ...@@ -169,20 +166,24 @@ def server ():
global StartTime global StartTime
udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
orig = ('', RECV_PORT) orig = ('', RECV_PORT)
dest = (HOST, SEND_PORT)
udp.bind(orig) udp.bind(orig)
protocolDescompactMessage = Protocol() protocolDescompactMessage = Protocol()
while True: while True:
msg, cliente = udp.recvfrom(1024) msg, cliente = udp.recvfrom(1024)
#print msg
protocolDescompactMessage.setDesempacota(msg) protocolDescompactMessage.setDesempacota(msg)
#print protocolDescompactMessage.msg
if (msg[1] == '1'): if (msg[1] == '1' and int(MACHINE_ID) == int(protocolDescompactMessage.destiny)):
print '\n' + protocolDescompactMessage.origin + ' Escreveu: ' + protocolDescompactMessage.msg print '\n' + protocolDescompactMessage.origin + ' Escreveu: ' + protocolDescompactMessage.msg
elif (msg[1] == '1'):
udp.sendto (msg, dest)
if (protocolDescompactMessage.type == '0' and TOKEN == 0): if (protocolDescompactMessage.type == '0' and TOKEN == 0):
print 'RECEBI O TOKEN' print 'RECEBI O TOKEN'
TOKEN = 1 TOKEN = 1
StartTime = time.time() StartTime = time.time()
udp.close() udp.close()
#------------------MAIN-----------------# #------------------MAIN-----------------#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment