Commit 58bf2c9d by Иван Кубота

connected event

parent bee4f43b
...@@ -112,7 +112,10 @@ const wss = new WebSocket.Server({ ...@@ -112,7 +112,10 @@ const wss = new WebSocket.Server({
// should not be compressed. // should not be compressed.
} }
}); });
console.log('WS LISTEN port: '+env.WS_PORT) wss.on('connection', function connection(ws) {
ws.send(JSON.stringify({type: 'connected', data: null}));
});
console.log('WS LISTEN port: '+env.WS_PORT);
global.log = function(type, data){ global.log = function(type, data){
try{ try{
wss.clients.forEach(function each(client) { wss.clients.forEach(function each(client) {
......
...@@ -57,10 +57,10 @@ ...@@ -57,10 +57,10 @@
padding: 4px; padding: 4px;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
} }
.correct { .question.correct {
background: #62ac6e; background: #62ac6e;
} }
.incorrect { .question.incorrect {
background: #ac6862; background: #ac6862;
} }
</style> </style>
...@@ -95,7 +95,11 @@ ...@@ -95,7 +95,11 @@
log = document.querySelectorAll('.log')[0]; log = document.querySelectorAll('.log')[0];
var attemptsHash = {}, var attemptsHash = {},
questionsHashGlobal = {}; questionsHashGlobal = {};
var actions = { var actions = {
connected: function(data){
D.div({cls: 'msg', renderTo: log}, D.span({cls: 'msg-bold'}, 'Connected'));
},
answerQuiz: function(data){ answerQuiz: function(data){
questionsHashGlobal[data.question.id].el.className = 'question '+(data.question.correct?'correct': 'incorrect') questionsHashGlobal[data.question.id].el.className = 'question '+(data.question.correct?'correct': 'incorrect')
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment