Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Tabu-Middleware
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
Tabu-Middleware
Commits
8e4cbe2b
Commit
8e4cbe2b
authored
Dec 31, 2020
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just one time can a new Round be startet
parent
f8d27eec
Pipeline
#328
passed with stages
in 3 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
events.js
events.js
+31
-6
socket.js
socket.js
+1
-1
No files found.
events.js
View file @
8e4cbe2b
const
express
=
require
(
'
express
'
);
const
io
=
require
(
"
socket.io-client
"
);
const
socket
=
io
(
'
ws://tabu-server.willers.digital
'
);
//const socket = io('ws://localhost:8
0');
//
const socket = io('ws://tabu-server.willers.digital');
const
socket
=
io
(
'
ws://localhost:300
0
'
);
function
createRouter
(
db
)
{
const
router
=
express
.
Router
();
...
...
@@ -184,6 +184,31 @@ function createRouter(db) {
}
};
const
isActiveExplainer
=
function
isActiveExplainer
(
req
,
res
,
next
)
{
const
spielname
=
req
.
body
.
spielname
;
if
(
spielname
.
match
(
/^
[
0-9a-zA-Z
]
+$/
)
!=
null
)
{
const
sql
=
'
SELECT ActiveExplainer FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName =
\
"
'
+
spielname
+
'
\
")
'
;
console
.
log
(
'
isActiveExplainer:
'
,
sql
)
db
.
query
(
sql
,
(
error
,
results
)
=>
{
console
.
log
(
'
Result:
'
,
results
);
if
(
error
)
{
console
.
log
(
error
);
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
false
'
,
reason
:
'
Round is active
'
});
}
else
{
const
activeExplainer
=
JSON
.
parse
(
results
[
0
].
ActiveExplainer
);
if
(
activeExplainer
===
0
)
{
next
();
}
else
{
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
false
'
,
reason
:
'
Round is active
'
});
}
}
}
);
}
};
const
newRound
=
function
newRound
(
req
,
res
)
{
const
spielname
=
req
.
body
.
spielname
;
if
(
spielname
.
match
(
/^
[
0-9a-zA-Z
]
+$/
)
!=
null
)
{
...
...
@@ -206,7 +231,7 @@ function createRouter(db) {
}
);
}
else
{
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
false
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
500
).
json
({
status
:
'
false
'
,
reason
:
'
Already Active Game
'
});
}
};
...
...
@@ -234,7 +259,7 @@ function createRouter(db) {
}
else
{
//res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'});
}
}
;
}
const
newGame
=
function
newGame
(
req
,
res
)
{
const
spielname
=
req
.
body
.
spielname
;
...
...
@@ -408,13 +433,13 @@ function createRouter(db) {
router
.
post
(
'
/getS2C
'
,
[
getS2C
]);
//Start a new Round and lock the game positions
router
.
post
(
'
/newRound
'
,
[
newRound
]);
router
.
post
(
'
/newRound
'
,
[
isActiveExplainer
,
newRound
]);
//End a Round and unlock the game positions and invert RedTurn
router
.
post
(
'
/endRound
'
,
[
endRound
]);
//Starts a new Game and resets red and blue and chooses a random value for RedTurn
router
.
post
(
'
/newGame
'
,
[
newGame
]);
router
.
post
(
'
/newGame
'
,
[
isActiveExplainer
,
newGame
]);
//Add Point
router
.
post
(
'
/addPoint
'
,
[
addPoint
]);
...
...
socket.js
View file @
8e4cbe2b
...
...
@@ -6,7 +6,7 @@ const Socketio = require("socket.io")(Http, {
}
});
Http
.
listen
(
8
0
,
()
=>
{
Http
.
listen
(
300
0
,
()
=>
{
console
.
log
(
"
Listening at :3000...
"
);
});
...
...
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