Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting
Commits
01a9fdf5
Commit
01a9fdf5
authored
Aug 21, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only response vote to the client who want to know his own vote
parent
02019657
Pipeline
#433
passed with stages
in 2 minutes and 49 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
socket.js
socket.js
+6
-6
No files found.
socket.js
View file @
01a9fdf5
...
...
@@ -83,10 +83,9 @@ server.on('connection',function(socket){
const
req
=
JSON
.
parse
(
data
);
hf
.
addMapToClient
(
clients
,
socket
,
req
[
'
mapId
'
],
newClientList
=>
{
clients
=
newClientList
.
slice
();
socket
.
write
(
JSON
.
stringify
(
res
.
data
)
+
'
\n
'
);
if
(
hf
.
checkIfRequestHasVote
(
data
))
{
sendToAllClientsAtSameMap
(
res
,
req
[
'
mapId
'
]);
}
else
{
socket
.
write
(
JSON
.
stringify
(
res
.
data
)
+
'
\n
'
);
sendToAllClientsAtSameMap
(
res
,
req
[
'
mapId
'
],
socket
);
}
});
//var is_kernel_buffer_full = socket.write(JSON.stringify(res.data) + '\n');
...
...
@@ -151,11 +150,12 @@ server.on('connection',function(socket){
}
// Send a message to all clients playing the same map
function
sendToAllClientsAtSameMap
(
res
,
mapId
)
{
function
sendToAllClientsAtSameMap
(
res
,
mapId
,
currentClient
)
{
console
.
log
(
"
JSON:
"
,
JSON
.
stringify
(
res
.
data
));
clients
.
forEach
(
function
(
client
)
{
// Don't want to send it to sender
if
(
client
.
mapId
===
mapId
)
client
.
write
(
JSON
.
stringify
(
res
.
data
)
+
'
\n
'
);
const
resJson
=
res
.
data
;
delete
resJson
[
'
vote
'
];
if
(
client
.
mapId
===
mapId
&&
client
.
name
!==
currentClient
)
client
.
write
(
JSON
.
stringify
(
resJson
)
+
'
\n
'
);
});
console
.
log
(
"
Write Message to all at
"
+
mapId
+
"
:
"
+
JSON
.
stringify
(
res
.
data
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment