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
06118dea
Commit
06118dea
authored
8 years ago
by
Fernando Erd
Browse files
Options
Downloads
Patches
Plain Diff
Token add
parent
93038531
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/CanguruChat.py
+17
-5
17 additions, 5 deletions
Canguru/CanguruChat.py
with
17 additions
and
5 deletions
Canguru/CanguruChat.py
+
17
−
5
View file @
06118dea
...
@@ -66,6 +66,12 @@ class Protocol():
...
@@ -66,6 +66,12 @@ class Protocol():
self
.
priority
=
raw_input
()
self
.
priority
=
raw_input
()
self
.
priority
=
str
(
self
.
priority
)
self
.
priority
=
str
(
self
.
priority
)
def
setType
(
self
):
if
(
self
.
msg
==
'
token
'
):
self
.
type
=
str
(
0
)
else
:
self
.
type
=
str
(
1
)
#set message
#set message
def
setMessage
(
self
):
def
setMessage
(
self
):
sys
.
stdout
.
write
(
'
Mensagem:
'
)
sys
.
stdout
.
write
(
'
Mensagem:
'
)
...
@@ -106,15 +112,19 @@ def client ():
...
@@ -106,15 +112,19 @@ def client ():
protocolMessage
.
setDestiny
()
protocolMessage
.
setDestiny
()
protocolMessage
.
setPriority
()
protocolMessage
.
setPriority
()
protocolMessage
.
setMessage
()
protocolMessage
.
setMessage
()
protocolMessage
.
setType
()
protocolMessage
.
setSizeof
()
protocolMessage
.
setSizeof
()
protocolMessage
.
setCRC32
()
protocolMessage
.
setCRC32
()
msg
=
protocolMessage
.
getEmpacotar
()
msg
=
protocolMessage
.
getEmpacotar
()
while
protocolMessage
.
msg
<>
'
exit
'
:
while
protocolMessage
.
msg
<>
'
exit
'
:
if
(
protocolMessage
.
type
==
0
):
print
'
Vou mandar o token
'
udp
.
sendto
(
msg
,
dest
)
udp
.
sendto
(
msg
,
dest
)
protocolMessage
=
Protocol
()
protocolMessage
=
Protocol
()
protocolMessage
.
setDestiny
()
protocolMessage
.
setDestiny
()
protocolMessage
.
setPriority
()
protocolMessage
.
setPriority
()
protocolMessage
.
setMessage
()
protocolMessage
.
setMessage
()
protocolMessage
.
setType
()
protocolMessage
.
setSizeof
()
protocolMessage
.
setSizeof
()
protocolMessage
.
setCRC32
()
protocolMessage
.
setCRC32
()
msg
=
protocolMessage
.
getEmpacotar
()
msg
=
protocolMessage
.
getEmpacotar
()
...
@@ -132,6 +142,8 @@ def server ():
...
@@ -132,6 +142,8 @@ def server ():
while
True
:
while
True
:
msg
,
cliente
=
udp
.
recvfrom
(
1024
)
msg
,
cliente
=
udp
.
recvfrom
(
1024
)
protocolDescompactMessage
.
setDesempacota
(
msg
)
protocolDescompactMessage
.
setDesempacota
(
msg
)
if
(
protocolDescompactMessage
.
type
==
'
0
'
):
print
'
RECEBI O TOKEN
'
if
protocolDescompactMessage
.
crc
==
protocolDescompactMessage
.
getCRC32
():
if
protocolDescompactMessage
.
crc
==
protocolDescompactMessage
.
getCRC32
():
print
msg
print
msg
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
print
'
\n
'
+
protocolDescompactMessage
.
origin
+
'
Escreveu:
'
+
protocolDescompactMessage
.
msg
...
@@ -142,9 +154,9 @@ def server ():
...
@@ -142,9 +154,9 @@ def server ():
#------------------MAIN-----------------#
#------------------MAIN-----------------#
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
AUX
=
RECV_PORT
TOKEN
=
1
RECV_PORT
=
SEND_PORT
print
'
COMECEI COM O TOKEN
'
SEND_PORT
=
AUX
print
"
Ip da proxima maquina
"
print
"
Ip da proxima maquina
"
HOST
=
raw_input
()
HOST
=
raw_input
()
threadServer
=
threading
.
Thread
(
target
=
server
)
threadServer
=
threading
.
Thread
(
target
=
server
)
...
...
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