Browse Source

Change sockets

Nikatlas 6 years ago
parent
commit
0ee7e8ea7b
1 changed files with 13 additions and 1 deletions
  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));
 		}
 	}