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
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
b4e81273
Commit
b4e81273
authored
8 years ago
by
Fernando Erd
Browse files
Options
Downloads
Patches
Plain Diff
so mando msg quando estou com o token
parent
96b15920
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
+12
-15
12 additions, 15 deletions
Canguru/tentandop.py
with
12 additions
and
15 deletions
Canguru/tentandop.py
+
12
−
15
View file @
b4e81273
...
@@ -115,6 +115,7 @@ class Protocol():
...
@@ -115,6 +115,7 @@ class Protocol():
def
token
():
def
token
():
global
TOKEN
global
TOKEN
global
StartTime
global
StartTime
global
queue
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
)
...
@@ -126,6 +127,14 @@ def token ():
...
@@ -126,6 +127,14 @@ def token ():
tokenMessage
.
type
=
str
(
0
)
tokenMessage
.
type
=
str
(
0
)
msg
=
tokenMessage
.
getEmpacotar
()
msg
=
tokenMessage
.
getEmpacotar
()
udp
.
sendto
(
msg
,
dest
)
udp
.
sendto
(
msg
,
dest
)
if
(
TOKEN
==
1
):
#print 'ESTOU COM O TOKEN'
if
(
not
queue
.
empty
()):
msg
=
queue
.
get
()
udp
.
sendto
(
msg
[
1
],
dest
)
print
'
ENVIANDO
'
#else:
#print 'A FILA ESTA VAZIA'
udp
.
close
()
udp
.
close
()
def
client
():
def
client
():
...
@@ -135,6 +144,7 @@ def client ():
...
@@ -135,6 +144,7 @@ def client ():
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
udp
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
dest
=
(
HOST
,
SEND_PORT
)
dest
=
(
HOST
,
SEND_PORT
)
protocolMessage
=
Protocol
()
protocolMessage
=
Protocol
()
global
queue
queue
=
Queue
.
PriorityQueue
()
queue
=
Queue
.
PriorityQueue
()
while
True
:
while
True
:
protocolMessage
.
setDestiny
()
protocolMessage
.
setDestiny
()
...
@@ -145,16 +155,8 @@ def client ():
...
@@ -145,16 +155,8 @@ def client ():
protocolMessage
.
setCRC32
()
protocolMessage
.
setCRC32
()
msg
=
protocolMessage
.
getEmpacotar
()
msg
=
protocolMessage
.
getEmpacotar
()
queue
.
put
((
protocolMessage
.
priority
,
msg
))
queue
.
put
((
protocolMessage
.
priority
,
msg
))
print
queue
.
queue
HighPriority
=
queue
.
queue
[
0
]
print
HighPriority
[
0
]
if
(
TOKEN
==
1
):
print
'
POSSO ENVIAR MSG
'
if
(
not
queue
.
empty
()):
if
(
not
queue
.
empty
()):
msg
=
queue
.
get
()
HighPriority
=
queue
.
queue
[
0
]
udp
.
sendto
(
msg
[
1
],
dest
)
print
'
ENVIANDO
'
print
msg
[
1
]
threadServer
.
_Thread__stop
()
threadServer
.
_Thread__stop
()
threadToken
.
_Thread__stop
()
threadToken
.
_Thread__stop
()
udp
.
close
()
udp
.
close
()
...
@@ -175,12 +177,7 @@ def server ():
...
@@ -175,12 +177,7 @@ def server ():
#print msg
#print msg
protocolDescompactMessage
.
setDesempacota
(
msg
)
protocolDescompactMessage
.
setDesempacota
(
msg
)
#print protocolDescompactMessage.msg
#print protocolDescompactMessage.msg
print
protocolDescompactMessage
.
type
print
msg
print
msg
[
1
]
if
(
msg
[
1
]
==
'
1
'
):
if
(
msg
[
1
]
==
'
1
'
):
print
'
LA
'
print
msg
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
if
(
protocolDescompactMessage
.
type
==
'
0
'
and
TOKEN
==
0
):
if
(
protocolDescompactMessage
.
type
==
'
0
'
and
TOKEN
==
0
):
...
...
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