Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CanguruChatServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fernando Erd
CanguruChatServer
Commits
ff742c9f
Commit
ff742c9f
authored
8 years ago
by
Fernando Erd
Browse files
Options
Downloads
Patches
Plain Diff
NACK add
parent
cac832ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Canguru/tentandop.py
+31
-8
31 additions, 8 deletions
Canguru/tentandop.py
with
31 additions
and
8 deletions
Canguru/tentandop.py
+
31
−
8
View file @
ff742c9f
...
@@ -36,6 +36,8 @@ import Queue
...
@@ -36,6 +36,8 @@ import Queue
global
TOKEN
global
TOKEN
global
StartTime
global
StartTime
global
HighPriority
global
HighPriority
global
RECEBIDA
RECEBIDA
=
1
StartTime
=
0
StartTime
=
0
HighPriority
=
10
HighPriority
=
10
TOKEN
=
0
TOKEN
=
0
...
@@ -115,6 +117,7 @@ def token ():
...
@@ -115,6 +117,7 @@ def token ():
global
TOKEN
global
TOKEN
global
StartTime
global
StartTime
global
queue
global
queue
global
RECEBIDA
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
tokenMessage
=
Protocol
()
tokenMessage
=
Protocol
()
dest
=
(
HOST
,
SEND_PORT
)
dest
=
(
HOST
,
SEND_PORT
)
...
@@ -132,8 +135,11 @@ def token ():
...
@@ -132,8 +135,11 @@ def token ():
msg
=
queue
.
get
()
msg
=
queue
.
get
()
udp
.
sendto
(
msg
[
1
],
dest
)
udp
.
sendto
(
msg
[
1
],
dest
)
print
'
ENVIANDO
'
print
'
ENVIANDO
'
#else:
time
.
sleep
(
1
)
#print 'A FILA ESTA VAZIA'
while
(
RECEBIDA
==
0
):
print
'
ENVIANDO NOVAMENTE A MSG
'
udp
.
sendto
(
msg
[
1
],
dest
)
time
.
sleep
(
1
)
udp
.
close
()
udp
.
close
()
def
client
():
def
client
():
...
@@ -164,6 +170,7 @@ def client ():
...
@@ -164,6 +170,7 @@ def client ():
def
server
():
def
server
():
global
TOKEN
global
TOKEN
global
StartTime
global
StartTime
global
RECEBIDA
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
)
dest
=
(
HOST
,
SEND_PORT
)
...
@@ -177,8 +184,16 @@ def server ():
...
@@ -177,8 +184,16 @@ def server ():
#A msg foi enviada com sucesso
#A msg foi enviada com sucesso
if
(
msg
[
1
]
==
'
2
'
and
int
(
MACHINE_ID
)
==
int
(
protocolDescompactMessage
.
destiny
)):
if
(
msg
[
1
]
==
'
2
'
and
int
(
MACHINE_ID
)
==
int
(
protocolDescompactMessage
.
destiny
)):
print
'
A MENSAGEM FOI ENVIADA COM SUCESSO
'
print
'
A MENSAGEM FOI ENVIADA COM SUCESSO
'
RECEBIDA
=
1
#Erro no envio
if
(
msg
[
1
]
==
'
3
'
and
int
(
MACHINE_ID
)
==
int
(
protocolDescompactMessage
.
destiny
)):
RECEBIDA
=
0
#A msg e pra mim
#A msg e pra mim
if
(
msg
[
1
]
==
'
1
'
and
int
(
MACHINE_ID
)
==
int
(
protocolDescompactMessage
.
destiny
)):
if
(
msg
[
1
]
==
'
1
'
and
int
(
MACHINE_ID
)
==
int
(
protocolDescompactMessage
.
destiny
)):
#protocolDescompactMessage.crc = "8888888"#caga tdo
if
(
protocolDescompactMessage
.
crc
==
protocolDescompactMessage
.
getCRC32
()):
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
#envia ack
#envia ack
...
@@ -186,6 +201,14 @@ def server ():
...
@@ -186,6 +201,14 @@ def server ():
protocolDescompactMessage
.
destiny
=
protocolDescompactMessage
.
origin
protocolDescompactMessage
.
destiny
=
protocolDescompactMessage
.
origin
msg
=
protocolDescompactMessage
.
getEmpacotar
()
msg
=
protocolDescompactMessage
.
getEmpacotar
()
udp
.
sendto
(
msg
,
dest
)
udp
.
sendto
(
msg
,
dest
)
else
:
print
'
ERRO DE MENSAGEM
'
#envia nack
protocolDescompactMessage
.
type
=
str
(
3
)
protocolDescompactMessage
.
destiny
=
protocolDescompactMessage
.
origin
msg
=
protocolDescompactMessage
.
getEmpacotar
()
udp
.
sendto
(
msg
,
dest
)
#A msg n e pra mim
#A msg n e pra mim
elif
(
msg
[
1
]
==
'
1
'
):
elif
(
msg
[
1
]
==
'
1
'
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment