Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
com2022-computer-networking
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Greer, Robyn P (UG - Comp Sci & Elec Eng)
com2022-computer-networking
Commits
3b6f98c4
Commit
3b6f98c4
authored
3 years ago
by
penguin0001
Browse files
Options
Downloads
Patches
Plain Diff
weird message handling etc
parent
db54c16a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client.py
+2
-2
2 additions, 2 deletions
client.py
server.py
+13
-9
13 additions, 9 deletions
server.py
with
15 additions
and
11 deletions
client.py
+
2
−
2
View file @
3b6f98c4
...
...
@@ -23,13 +23,13 @@ def send(msg):
connect
=
True
print
(
"
You may use BYE to close the connection at any time.
"
)
user_input
=
input
(
"
Enter username:
"
)
print
(
"
[you may use BYE to close the connection at any time]
"
)
while
connect
:
server_msg
=
send
(
user_input
)
print
(
server_msg
)
user_input
=
input
()
if
user_input
.
upper
()
==
"
BYE
"
or
server_msg
==
"
ERR
"
:
if
user_input
.
upper
()
==
"
BYE
"
or
server_msg
==
"
ERR
"
or
server_msg
==
"
DONE
"
or
server_msg
==
"
END
"
:
connect
=
False
...
...
This diff is collapsed.
Click to expand it.
server.py
+
13
−
9
View file @
3b6f98c4
...
...
@@ -23,7 +23,7 @@ orders = {}
chef_present
=
True
global
user
global
state
# one of: LOGIN, CUSTOMER, NEW, STARTER, MAIN, SIDE, OLD
global
state
# one of: LOGIN, CUSTOMER, NEW, STARTER, MAIN, SIDE, OLD
, DONE
def
handle_message
(
msg
):
...
...
@@ -35,7 +35,7 @@ def handle_message(msg):
state
=
"
CUSTOMER
"
return
"
NEW or OLD customer?
"
else
:
return
"
Username invalid.
"
return
"
Enter username:
"
if
state
==
'
CUSTOMER
'
:
if
msg
.
upper
()
==
"
NEW
"
:
...
...
@@ -45,7 +45,7 @@ def handle_message(msg):
state
=
'
OLD
'
return
'
PKUP?
'
else
:
return
"
ERR
\n
NEW or OLD?
"
return
"
NEW or OLD?
"
if
state
==
"
NEW
"
:
if
msg
.
upper
()
==
"
MENU
"
:
...
...
@@ -54,7 +54,7 @@ def handle_message(msg):
state
=
"
STARTER
"
return
"
Select starter:
"
else
:
return
"
ERR
\n
MENU or ORDR?
"
return
"
MENU or ORDR?
"
if
state
==
"
STARTER
"
:
if
is_starter
(
msg
.
lower
()):
...
...
@@ -63,7 +63,7 @@ def handle_message(msg):
state
=
"
MAIN
"
return
"
Select main:
"
else
:
return
"
ERR
\n
Select starter:
"
return
"
Select starter:
"
if
state
==
"
MAIN
"
:
if
is_main
(
msg
.
lower
()):
...
...
@@ -71,23 +71,27 @@ def handle_message(msg):
state
=
"
SIDE
"
return
"
Select side:
"
else
:
return
"
ERR
\n
Select main:
"
return
"
Select main:
"
if
state
==
"
SIDE
"
:
if
is_side
(
msg
.
lower
()):
orders
[
user
].
append
(
msg
.
lower
())
state
=
"
DONE
"
return
"
DONE
"
else
:
return
"
ERR
\n
Select side:
"
return
"
Select side:
"
if
state
==
"
DONE
"
:
return
"
DONE
"
if
state
==
"
OLD
"
:
if
msg
.
upper
()
==
"
PKUP
"
:
if
user
in
orders
:
return
orders_to_string
(
user
)
return
orders_to_string
(
user
)
+
"
\n
Order picked up, you may close the connection.
"
else
:
return
"
You don
'
t have any orders to pick up. Please close the connection.
"
else
:
return
"
ERR
\n
PKUP?
"
return
"
PKUP?
"
else
:
return
'
ERR
'
...
...
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