Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2doku
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kes444
2doku
Commits
72dc99ae
Commit
72dc99ae
authored
Aug 29, 2023
by
Patrick
Browse files
Options
Downloads
Patches
Plain Diff
Added code to handle duplicate users.
parent
2d459c9f
No related branches found
No related tags found
1 merge request
!1
Update 1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/semipublic/game.html
+10
-9
10 additions, 9 deletions
app/semipublic/game.html
app/server.js
+3
-1
3 additions, 1 deletion
app/server.js
with
13 additions
and
10 deletions
app/semipublic/game.html
+
10
−
9
View file @
72dc99ae
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
</head>
</head>
<body>
<body>
<h1>
2doku
</h1>
<h1>
2doku
</h1>
<div
id=
"error-container"
></div>
<div
id=
"player-info-container"
>
<div
id=
"player-info-container"
>
<h2
id=
"score-header"
>
Player Scores
</h2>
<h2
id=
"score-header"
>
Player Scores
</h2>
</div>
</div>
...
@@ -23,11 +23,6 @@
...
@@ -23,11 +23,6 @@
.
filter
(
c
=>
c
[
0
]
===
"
token
"
)[
0
];
.
filter
(
c
=>
c
[
0
]
===
"
token
"
)[
0
];
return
t
?
t
[
1
]
:
null
;
return
t
?
t
[
1
]
:
null
;
}
}
function
hideJoinButton
()
{
document
.
querySelector
(
"
#join-game
"
).
style
.
display
=
"
none
"
;
}
const
socket
=
io
({
const
socket
=
io
({
query
:
{
query
:
{
gameId
:
window
.
location
.
href
.
split
(
"
/
"
).
filter
(
e
=>
e
.
length
>
0
).
pop
(),
gameId
:
window
.
location
.
href
.
split
(
"
/
"
).
filter
(
e
=>
e
.
length
>
0
).
pop
(),
...
@@ -42,7 +37,7 @@
...
@@ -42,7 +37,7 @@
BOARD1
.
updateBoard
(
args
.
boardDisplay
,
args
.
boardLock
,
args
.
boardColors
);
BOARD1
.
updateBoard
(
args
.
boardDisplay
,
args
.
boardLock
,
args
.
boardColors
);
document
.
querySelector
(
"
#join-game
"
).
style
.
display
=
"
none
"
;
document
.
querySelector
(
"
#join-game
"
).
style
.
display
=
"
none
"
;
displayPlayerScores
(
args
.
playerScores
);
displayPlayerScores
(
args
.
playerScores
);
hideJoinB
ut
t
on
(
);
socket
.
emit
(
"
verify sol
ut
i
on
"
,
args
.
boardDisplay
);
});
});
socket
.
on
(
"
game stop
"
,
()
=>
{
socket
.
on
(
"
game stop
"
,
()
=>
{
...
@@ -50,8 +45,14 @@
...
@@ -50,8 +45,14 @@
});
});
document
.
querySelector
(
"
#join-game
"
).
onclick
=
()
=>
{
document
.
querySelector
(
"
#join-game
"
).
onclick
=
()
=>
{
socket
.
emit
(
"
join game
"
);
socket
.
emit
(
"
join game
"
,
null
,
(
duplicate
)
=>
{
hideJoinButton
();
if
(
duplicate
)
{
document
.
querySelector
(
"
#error-container
"
).
textContent
=
"
Sorry, but you logged in as a duplicate user.
"
;
document
.
querySelector
(
"
#player-info-container
"
).
style
.
display
=
"
none
"
;
document
.
querySelector
(
"
#board-container
"
).
style
.
display
=
"
none
"
;
}
});
document
.
querySelector
(
"
#join-game
"
).
style
.
display
=
"
none
"
;
}
}
function
updateToServer
(
x
,
y
,
num
)
{
function
updateToServer
(
x
,
y
,
num
)
{
...
...
This diff is collapsed.
Click to expand it.
app/server.js
+
3
−
1
View file @
72dc99ae
...
@@ -297,9 +297,11 @@ io.on("connection", (socket) => {
...
@@ -297,9 +297,11 @@ io.on("connection", (socket) => {
game
.
sendBoard
();
game
.
sendBoard
();
});
});
socket
.
on
(
"
join game
"
,
()
=>
{
socket
.
on
(
"
join game
"
,
(
_
,
fn
)
=>
{
if
(
!
game
.
playerUsers
.
includes
(
user
))
{
if
(
!
game
.
playerUsers
.
includes
(
user
))
{
game
.
userJoin
(
socketId
,
user
);
game
.
userJoin
(
socketId
,
user
);
}
else
{
fn
(
"
duplicate
"
);
}
}
});
});
...
...
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
sign in
to comment