在官方结构样本中的balance-transfer sample (typescript version)中,客户端没有在通道上设置任何锚定对等体。我检查了客户端中exports.getQRCode = functions.https.onRequest((req, res) => {
admin.database().ref('lockers/LocationA/empty').limitToFirst(1).once("value", snap=> {
// Get the name of the first available door and use a transaction to ensure it is not occupied
console.log('QR Code for door:',snap.val());
var door = Object.keys(snap.val())[0];
console.log('door:',door);
// var door = snap.key();
var occupiedRef = admin.database().ref('lockers/LocationA/occupied/'+door);
occupiedRef.transaction(currentData=> {
if (currentData === null) {
console.log("Door does not already exist under /occupied, so we can use this one.");
return snap.child(door).val(); // Save the chosen door to /occupied
} else {
console.log('The door already exists under /occupied.');
return nil; // Abort the transaction by returning nothing
}
}, (error, committed, snapshot) => {
console.log('snap.val():',snap.val());
if (error) {
console.log('Transaction failed abnormally!', error);
res.send("Unknown error."); // This handles any abormal error
} else if (!committed) {
console.log('We aborted the transaction (because the door is already occupied).');
res.redirect(req.originalUrl); // Refresh the page so that the request is retried
} else {
// The door is not occupied, so can be given to this user
admin.database().ref('lockers/LocationA/empty/'+door).remove(); // Delete the door from /empty
console.log('QR Code for door:',snapshot.val());
var qrCodesForDoor = snapshot.val();
res.send(qrCodesForDoor); // Send the chosen door as the response
}
});
});
});
对象的_anchor_peers
属性是否为空。
那么,通道上没有主播同伴可以吗?或者,当我们没有明确指定它们时,是否会自动设置默认锚点对等体?
答案 0 :(得分:3)
锚定对等体为对等体启用跨组织通信。没有默认的锚点对等体,您必须明确声明一个。在频道上没有一个仍然允许同一个组织的同伴能够进行通信。