浏览代码

Implement Sockets

Nikatlas 6 年之前
父节点
当前提交
8249126c3f
共有 1 个文件被更改,包括 10 次插入1 次删除
  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
     }