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

+ 13 - 1
services/matchmaking/randomFree.js

@@ -6,6 +6,7 @@ class randomFree {
 	constructor() {
 		nsp.on('connection', (socket) => {
 		  console.log('someone connected');
+		  socket.join('queue');
 		  this.match();
 		});
 	}
@@ -13,8 +14,19 @@ class randomFree {
 	match() {
 		let clients = Object.keys(nsp.sockets);
 		console.log(clients);
-		if(clients.length > 1) {
+		if(clients.length > 21) {
+			let p1 = nsp.sockets[clients[0]];
+			let p2 = nsp.sockets[clients[1]];
 
+			//p1.leave('queue');
+			//p1.join(clients[0] + clients[1]);
+			//p2.leave('queue');
+			//p2.join(clients[0] + clients[1]);
+
+			
+			console.log(io.sockets.adapter.sids);
+			console.log("Matched!");
+			console.log(Object.keys(nsp.to('queue').sockets));
 		}
 	}