mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:52:57 +02:00
handle cleanup, race, etc..., more to come
This commit is contained in:
parent
fa7283a6e2
commit
7765daf382
1 changed files with 6 additions and 7 deletions
|
@ -158,7 +158,6 @@ function startHandshake(fromKeyboard) {
|
||||||
pendingFriendAckFrom = undefined;
|
pendingFriendAckFrom = undefined;
|
||||||
// if we have a recent friendRequest, send an ack back
|
// if we have a recent friendRequest, send an ack back
|
||||||
if (latestFriendRequestFrom) {
|
if (latestFriendRequestFrom) {
|
||||||
debug("sending friendAck to", latestFriendRequestFrom);
|
|
||||||
messageSend({
|
messageSend({
|
||||||
key: "friendAck",
|
key: "friendAck",
|
||||||
id: latestFriendRequestFrom,
|
id: latestFriendRequestFrom,
|
||||||
|
@ -166,10 +165,8 @@ function startHandshake(fromKeyboard) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var nearestAvatar = findNearbyAvatars(true)[0];
|
var nearestAvatar = findNearbyAvatars(true)[0];
|
||||||
debug("nearest avatar", nearestAvatar);
|
|
||||||
if (nearestAvatar) {
|
if (nearestAvatar) {
|
||||||
pendingFriendAckFrom = nearestAvatar.avatar;
|
pendingFriendAckFrom = nearestAvatar.avatar;
|
||||||
debug("sending friendRequest to", pendingFriendAckFrom);
|
|
||||||
messageSend({
|
messageSend({
|
||||||
key: "friendRequest",
|
key: "friendRequest",
|
||||||
id: nearestAvatar.avatar,
|
id: nearestAvatar.avatar,
|
||||||
|
@ -314,14 +311,13 @@ function messageHandler(channel, messageString, senderID) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debug(e);
|
debug(e);
|
||||||
}
|
}
|
||||||
debug("message", message);
|
|
||||||
switch (message.key) {
|
switch (message.key) {
|
||||||
case "friendRequest":
|
case "friendRequest":
|
||||||
if (state == STATES.inactive && message.id == MyAvatar.sessionUUID) {
|
if (state == STATES.inactive && message.id == MyAvatar.sessionUUID) {
|
||||||
debug("setting latestFriendRequestFrom", senderID);
|
|
||||||
latestFriendRequestFrom = senderID;
|
latestFriendRequestFrom = senderID;
|
||||||
} else if (state == STATES.waiting && !pendingFriendAckFrom) {
|
} else if (state == STATES.waiting && (pendingFriendAckFrom == senderID || !pendingFriendAckFrom)) {
|
||||||
// you are waiting for a friend request, so send the ack
|
// you are waiting for a friend request, so send the ack. Or, you and the other
|
||||||
|
// guy raced and both send friendRequests. Handle that too
|
||||||
pendingFriendAckFrom = senderID;
|
pendingFriendAckFrom = senderID;
|
||||||
messageSend({
|
messageSend({
|
||||||
key: "friendAck",
|
key: "friendAck",
|
||||||
|
@ -436,5 +432,8 @@ Script.scriptEnding.connect(function () {
|
||||||
Controller.keyReleaseEvent.disconnect(keyReleaseEvent);
|
Controller.keyReleaseEvent.disconnect(keyReleaseEvent);
|
||||||
debug("disconnecting updateVisualization");
|
debug("disconnecting updateVisualization");
|
||||||
Script.update.disconnect(updateVisualization);
|
Script.update.disconnect(updateVisualization);
|
||||||
|
if (entity) {
|
||||||
|
entity = Entities.deleteEntity(entity);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue