mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-17 12:26:16 +02:00
Merge pull request #10431 from davidkelly/dk/messageLoggedInStatus
minor handshake script update
This commit is contained in:
commit
3c652a52d8
1 changed files with 20 additions and 9 deletions
|
@ -366,6 +366,8 @@
|
||||||
return nearestAvatar;
|
return nearestAvatar;
|
||||||
}
|
}
|
||||||
function messageSend(message) {
|
function messageSend(message) {
|
||||||
|
// we always append whether or not we are logged in...
|
||||||
|
message.isLoggedIn = Account.isLoggedIn();
|
||||||
Messages.sendMessage(MESSAGE_CHANNEL, JSON.stringify(message));
|
Messages.sendMessage(MESSAGE_CHANNEL, JSON.stringify(message));
|
||||||
}
|
}
|
||||||
function handStringMessageSend(message) {
|
function handStringMessageSend(message) {
|
||||||
|
@ -463,7 +465,9 @@
|
||||||
endHandshakeAnimation();
|
endHandshakeAnimation();
|
||||||
// No-op if we were successful, but this way we ensure that failures and abandoned handshakes don't leave us
|
// No-op if we were successful, but this way we ensure that failures and abandoned handshakes don't leave us
|
||||||
// in a weird state.
|
// in a weird state.
|
||||||
request({ uri: requestUrl, method: 'DELETE' }, debug);
|
if (Account.isLoggedIn()) {
|
||||||
|
request({ uri: requestUrl, method: 'DELETE' }, debug);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTriggers(value, fromKeyboard, hand) {
|
function updateTriggers(value, fromKeyboard, hand) {
|
||||||
|
@ -590,7 +594,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeConnection(id) {
|
function makeConnection(id, isLoggedIn) {
|
||||||
// send done to let the connection know you have made connection.
|
// send done to let the connection know you have made connection.
|
||||||
messageSend({
|
messageSend({
|
||||||
key: "done",
|
key: "done",
|
||||||
|
@ -606,7 +610,10 @@
|
||||||
// It would be "simpler" to skip this and just look at the response, but:
|
// It would be "simpler" to skip this and just look at the response, but:
|
||||||
// 1. We don't want to bother the metaverse with request that we know will fail.
|
// 1. We don't want to bother the metaverse with request that we know will fail.
|
||||||
// 2. We don't want our code here to be dependent on precisely how the metaverse responds (400, 401, etc.)
|
// 2. We don't want our code here to be dependent on precisely how the metaverse responds (400, 401, etc.)
|
||||||
if (!Account.isLoggedIn()) {
|
// 3. We also don't want to connect to someone who is anonymous _now_, but was not earlier and still has
|
||||||
|
// the same node id. Since the messaging doesn't say _who_ isn't logged in, fail the same as if we are
|
||||||
|
// not logged in.
|
||||||
|
if (!Account.isLoggedIn() || isLoggedIn === false) {
|
||||||
handleConnectionResponseAndMaybeRepeat("401:Unauthorized", {statusCode: 401});
|
handleConnectionResponseAndMaybeRepeat("401:Unauthorized", {statusCode: 401});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -628,8 +635,12 @@
|
||||||
// we change states, start the connectionInterval where we check
|
// we change states, start the connectionInterval where we check
|
||||||
// to be sure the hand is still close enough. If not, we terminate
|
// to be sure the hand is still close enough. If not, we terminate
|
||||||
// the interval, go back to the waiting state. If we make it
|
// the interval, go back to the waiting state. If we make it
|
||||||
// the entire CONNECTING_TIME, we make the connection.
|
// the entire CONNECTING_TIME, we make the connection. We pass in
|
||||||
function startConnecting(id, jointIndex) {
|
// whether or not the connecting id is actually logged in, as now we
|
||||||
|
// will allow to start the connection process but have it stop with a
|
||||||
|
// fail message before trying to call the backend if the other guy isn't
|
||||||
|
// logged in.
|
||||||
|
function startConnecting(id, jointIndex, isLoggedIn) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
debug("connecting", id, "hand", jointIndex);
|
debug("connecting", id, "hand", jointIndex);
|
||||||
// do we need to do this?
|
// do we need to do this?
|
||||||
|
@ -671,7 +682,7 @@
|
||||||
startHandshake();
|
startHandshake();
|
||||||
} else if (count > CONNECTING_TIME / CONNECTING_INTERVAL) {
|
} else if (count > CONNECTING_TIME / CONNECTING_INTERVAL) {
|
||||||
debug("made connection with " + id);
|
debug("made connection with " + id);
|
||||||
makeConnection(id);
|
makeConnection(id, isLoggedIn);
|
||||||
stopConnecting();
|
stopConnecting();
|
||||||
}
|
}
|
||||||
}, CONNECTING_INTERVAL);
|
}, CONNECTING_INTERVAL);
|
||||||
|
@ -736,7 +747,7 @@
|
||||||
if (state === STATES.WAITING && (!connectingId || connectingId === senderID)) {
|
if (state === STATES.WAITING && (!connectingId || connectingId === senderID)) {
|
||||||
if (message.id === MyAvatar.sessionUUID) {
|
if (message.id === MyAvatar.sessionUUID) {
|
||||||
stopWaiting();
|
stopWaiting();
|
||||||
startConnecting(senderID, exisitingOrSearchedJointIndex());
|
startConnecting(senderID, exisitingOrSearchedJointIndex(), message.isLoggedIn);
|
||||||
} else if (connectingId) {
|
} else if (connectingId) {
|
||||||
// this is for someone else (we lost race in connectionRequest),
|
// this is for someone else (we lost race in connectionRequest),
|
||||||
// so lets start over
|
// so lets start over
|
||||||
|
@ -755,7 +766,7 @@
|
||||||
startHandshake();
|
startHandshake();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startConnecting(senderID, connectingHandJointIndex);
|
startConnecting(senderID, connectingHandJointIndex, message.isLoggedIn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "done":
|
||||||
|
@ -775,7 +786,7 @@
|
||||||
} else {
|
} else {
|
||||||
// they just created a connection request to us, and we are connecting to
|
// they just created a connection request to us, and we are connecting to
|
||||||
// them, so lets just stop connecting and make connection..
|
// them, so lets just stop connecting and make connection..
|
||||||
makeConnection(connectingId);
|
makeConnection(connectingId, message.isLoggedIn);
|
||||||
stopConnecting();
|
stopConnecting();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue