Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
51f0ad11
Commit
51f0ad11
authored
Jul 07, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no socket
parent
c0d0b8d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
api.js
api.js
+7
-2
monitor.html
public/monitor.html
+16
-2
quiz.js
src/api/quiz.js
+11
-0
No files found.
api.js
View file @
51f0ad11
...
@@ -116,12 +116,17 @@ wss.on('connection', function connection(ws) {
...
@@ -116,12 +116,17 @@ wss.on('connection', function connection(ws) {
ws
.
send
(
JSON
.
stringify
({
type
:
'connected'
,
data
:
null
}));
ws
.
send
(
JSON
.
stringify
({
type
:
'connected'
,
data
:
null
}));
});
});
console
.
log
(
'WS LISTEN port: '
+
env
.
WS_PORT
);
console
.
log
(
'WS LISTEN port: '
+
env
.
WS_PORT
);
var
logging
=
[];
global
.
log
=
function
(
type
,
data
){
global
.
log
=
function
(
type
,
data
){
try
{
try
{
logging
.
push
({
date
:
+
new
Date
(),
type
,
data
});
wss
.
clients
.
forEach
(
function
each
(
client
)
{
wss
.
clients
.
forEach
(
function
each
(
client
)
{
client
.
send
(
JSON
.
stringify
({
type
,
data
}));
client
.
send
(
JSON
.
stringify
({
type
,
data
}));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
}
}
}
}
\ No newline at end of file
global
.
log
.
logging
=
logging
;
\ No newline at end of file
public/monitor.html
View file @
51f0ad11
...
@@ -140,14 +140,28 @@
...
@@ -140,14 +140,28 @@
if
(
code
.
join
(
'91'
)
===
'1391666911391666'
){
if
(
code
.
join
(
'91'
)
===
'1391666911391666'
){
hh1
.
style
.
display
=
'none'
;
hh1
.
style
.
display
=
'none'
;
hh2
.
style
.
display
=
'block'
;
hh2
.
style
.
display
=
'block'
;
var
begin
=
0
;
setInterval
(
function
()
{
fetch
(
'http://vkusvill.flexlab.pro:4001/api/quiz/monitordata?start='
+
begin
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
debugger
;
data
;
data
.
forEach
(
data
=>
{
actions
[
data
.
type
](
data
.
data
);
begin
=
data
.
date
;
})
}
);
},
1000
);
let
socket
=
new
WebSocket
(
'ws://'
+
location
.
hostname
+
':8080'
);
let
socket
=
new
WebSocket
(
'ws://'
+
location
.
hostname
+
':8080'
);
socket
.
onmessage
=
function
(
event
)
{
/*
socket.onmessage = function(event) {
var data = JSON.parse(event.data);
var data = JSON.parse(event.data);
actions[data.type](data.data);
actions[data.type](data.data);
};
};
*/
}
}
};
};
/*code = [0,13,666,13,666];
/*code = [0,13,666,13,666];
...
...
src/api/quiz.js
View file @
51f0ad11
...
@@ -274,5 +274,15 @@ module.exports = {
...
@@ -274,5 +274,15 @@ module.exports = {
return
(
await
readFile
(
'./public/monitor.html'
)).
toString
(
'utf-8'
);
return
(
await
readFile
(
'./public/monitor.html'
)).
toString
(
'utf-8'
);
}
}
},
'/api/quiz/monitordata'
:
{
method
:
'GET'
,
options
:
{
start
:
{
required
:
false
,
description
:
'begin date'
,
type
:
Number
},
},
summary
:
'monitordata'
,
fn
:
async
function
(
args
,
req
,
res
){
return
log
.
logging
.
filter
(
l
=>
l
.
start
>=
args
.
start
);
}
}
}
};
};
\ No newline at end of file
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