mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 02:35:16 +02:00
make connection messaging when not logged in
This commit is contained in:
parent
ec2ebc00c0
commit
b089fd03b8
1 changed files with 15 additions and 2 deletions
|
@ -131,7 +131,6 @@ function request(options, callback) { // cb(error, responseOfCorrectContentType)
|
||||||
var error = (httpRequest.status !== HTTP_OK) && httpRequest.status.toString() + ':' + httpRequest.statusText,
|
var error = (httpRequest.status !== HTTP_OK) && httpRequest.status.toString() + ':' + httpRequest.statusText,
|
||||||
response = !error && httpRequest.responseText,
|
response = !error && httpRequest.responseText,
|
||||||
contentType = !error && httpRequest.getResponseHeader('content-type');
|
contentType = !error && httpRequest.getResponseHeader('content-type');
|
||||||
debug('FIXME REMOVE: server response', options, error, response, contentType);
|
|
||||||
if (!error && contentType.indexOf('application/json') === 0) { // ignoring charset, etc.
|
if (!error && contentType.indexOf('application/json') === 0) { // ignoring charset, etc.
|
||||||
try {
|
try {
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
|
@ -139,6 +138,9 @@ function request(options, callback) { // cb(error, responseOfCorrectContentType)
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
response = {statusCode: httpRequest.status};
|
||||||
|
}
|
||||||
callback(error, response);
|
callback(error, response);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -164,7 +166,6 @@ function request(options, callback) { // cb(error, responseOfCorrectContentType)
|
||||||
options.headers["Content-type"] = "application/json";
|
options.headers["Content-type"] = "application/json";
|
||||||
options.body = JSON.stringify(options.body);
|
options.body = JSON.stringify(options.body);
|
||||||
}
|
}
|
||||||
debug("FIXME REMOVE: final options to send", options);
|
|
||||||
for (key in options.headers || {}) {
|
for (key in options.headers || {}) {
|
||||||
httpRequest.setRequestHeader(key, options.headers[key]);
|
httpRequest.setRequestHeader(key, options.headers[key]);
|
||||||
}
|
}
|
||||||
|
@ -574,6 +575,9 @@ function handleConnectionResponseAndMaybeRepeat(error, response) {
|
||||||
}
|
}
|
||||||
} else if (error || (response.status !== 'success')) {
|
} else if (error || (response.status !== 'success')) {
|
||||||
debug('server fail', error, response.status);
|
debug('server fail', error, response.status);
|
||||||
|
if (response && (response.statusCode === 401)) {
|
||||||
|
error = "All participants must be logged in to connect.";
|
||||||
|
}
|
||||||
result = error ? {status: 'error', connection: error} : response;
|
result = error ? {status: 'error', connection: error} : response;
|
||||||
UserActivityLogger.makeUserConnection(connectingId, false, error || response);
|
UserActivityLogger.makeUserConnection(connectingId, false, error || response);
|
||||||
connectionRequestCompleted();
|
connectionRequestCompleted();
|
||||||
|
@ -603,6 +607,15 @@ function makeConnection(id) {
|
||||||
// probably, in which we do this.
|
// probably, in which we do this.
|
||||||
Controller.triggerHapticPulse(HAPTIC_DATA.background.strength, MAKING_CONNECTION_TIMEOUT, handToHaptic(currentHand));
|
Controller.triggerHapticPulse(HAPTIC_DATA.background.strength, MAKING_CONNECTION_TIMEOUT, handToHaptic(currentHand));
|
||||||
requestBody = {node_id: cleanId(MyAvatar.sessionUUID), proposed_node_id: cleanId(id)}; // for use when repeating
|
requestBody = {node_id: cleanId(MyAvatar.sessionUUID), proposed_node_id: cleanId(id)}; // for use when repeating
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
// 2. We don't want our code here to be dependent on precisely how the metaverse responds (400, 401, etc.)
|
||||||
|
if (!Account.isLoggedIn()) {
|
||||||
|
handleConnectionResponseAndMaybeRepeat("401:Unauthorized", {statusCode: 401});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// This will immediately set response if successfull (e.g., the other guy got his request in first), or immediate failure,
|
// This will immediately set response if successfull (e.g., the other guy got his request in first), or immediate failure,
|
||||||
// and will otherwise poll (using the requestBody we just set).
|
// and will otherwise poll (using the requestBody we just set).
|
||||||
request({ //
|
request({ //
|
||||||
|
|
Loading…
Reference in a new issue