Pārlūkot izejas kodu

Implement Sockets

Nikatlas 6 gadi atpakaļ
vecāks
revīzija
8249126c3f
1 mainītis faili ar 10 papildinājumiem un 1 dzēšanām
  1. 10 1
      services/matchmaking/randomFree.js

+ 10 - 1
services/matchmaking/randomFree.js

@@ -4,11 +4,20 @@ const nsp = io.of('/randomFree');
 class randomFree {
 
 	constructor() {
-		nsp.on('connection', function(socket){
+		nsp.on('connection', (socket) => {
 		  console.log('someone connected');
+		  this.match();
 		});
 	}
 
+	match() {
+		let clients = Object.keys(nsp.sockets);
+		console.log(clients);
+		if(clients.length > 1) {
+
+		}
+	}
+
     join(user){
         //join randomFree queue room
     }