|
@@ -6,6 +6,7 @@ class randomFree {
|
|
constructor() {
|
|
constructor() {
|
|
nsp.on('connection', (socket) => {
|
|
nsp.on('connection', (socket) => {
|
|
console.log('someone connected');
|
|
console.log('someone connected');
|
|
|
|
+ socket.join('queue');
|
|
this.match();
|
|
this.match();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -13,8 +14,19 @@ class randomFree {
|
|
match() {
|
|
match() {
|
|
let clients = Object.keys(nsp.sockets);
|
|
let clients = Object.keys(nsp.sockets);
|
|
console.log(clients);
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|