mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 23:00:18 +02:00
setupCandidate
This commit is contained in:
parent
18dbe3568c
commit
d41a911fd2
1 changed files with 15 additions and 22 deletions
|
@ -439,6 +439,19 @@
|
||||||
message[HAND_STRING_PROPERTY] = handString;
|
message[HAND_STRING_PROPERTY] = handString;
|
||||||
messageSend(message);
|
messageSend(message);
|
||||||
}
|
}
|
||||||
|
function setupCandidate() { // find the closest in-range avatar, send connection request, an return true. (Otherwise falsey)
|
||||||
|
var nearestAvatar = findNearestWaitingAvatar();
|
||||||
|
if (nearestAvatar.avatar) {
|
||||||
|
connectingId = nearestAvatar.avatar;
|
||||||
|
connectingHandString = handToString(nearestAvatar.hand);
|
||||||
|
debug("sending connectionRequest to", connectingId);
|
||||||
|
handStringMessageSend({
|
||||||
|
key: "connectionRequest",
|
||||||
|
id: connectingId
|
||||||
|
}, handToString(currentHand));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function lookForWaitingAvatar() {
|
function lookForWaitingAvatar() {
|
||||||
// we started with nobody close enough, but maybe I've moved
|
// we started with nobody close enough, but maybe I've moved
|
||||||
|
@ -451,17 +464,7 @@
|
||||||
debug("started looking for waiting avatars");
|
debug("started looking for waiting avatars");
|
||||||
waitingInterval = Script.setInterval(function () {
|
waitingInterval = Script.setInterval(function () {
|
||||||
if (state === STATES.WAITING && !connectingId) {
|
if (state === STATES.WAITING && !connectingId) {
|
||||||
// find the closest in-range avatar, and send connection request
|
setupCandidate();
|
||||||
var nearestAvatar = findNearestWaitingAvatar();
|
|
||||||
if (nearestAvatar.avatar) {
|
|
||||||
connectingId = nearestAvatar.avatar;
|
|
||||||
connectingHandString = handToString(nearestAvatar.hand);
|
|
||||||
debug("sending connectionRequest to", connectingId);
|
|
||||||
handStringMessageSend({
|
|
||||||
key: "connectionRequest",
|
|
||||||
id: connectingId
|
|
||||||
}, handToString(currentHand));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// something happened, stop looking for avatars to connect
|
// something happened, stop looking for avatars to connect
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
|
@ -490,18 +493,8 @@
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
stopConnecting();
|
stopConnecting();
|
||||||
stopMakingConnection();
|
stopMakingConnection();
|
||||||
|
if (setupCandidate()) {
|
||||||
var nearestAvatar = findNearestWaitingAvatar();
|
|
||||||
if (nearestAvatar.avatar) {
|
|
||||||
connectingId = nearestAvatar.avatar;
|
|
||||||
connectingHandString = handToString(nearestAvatar.hand);
|
|
||||||
connectingHandJointIndex = getIdealHandJointIndex(nearestAvatar.avatarObject, nearestAvatar.hand);
|
|
||||||
currentHandJointIndex = getIdealHandJointIndex(MyAvatar, currentHand);
|
currentHandJointIndex = getIdealHandJointIndex(MyAvatar, currentHand);
|
||||||
debug("sending connectionRequest to", connectingId);
|
|
||||||
handStringMessageSend({
|
|
||||||
key: "connectionRequest",
|
|
||||||
id: connectingId,
|
|
||||||
}, handToString(currentHand));
|
|
||||||
} else {
|
} else {
|
||||||
// send waiting message
|
// send waiting message
|
||||||
debug("sending waiting message");
|
debug("sending waiting message");
|
||||||
|
|
Loading…
Reference in a new issue