mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 08:56:36 +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;
|
||||
// if we have a recent friendRequest, send an ack back
|
||||
if (latestFriendRequestFrom) {
|
||||
debug("sending friendAck to", latestFriendRequestFrom);
|
||||
messageSend({
|
||||
key: "friendAck",
|
||||
id: latestFriendRequestFrom,
|
||||
|
@ -166,10 +165,8 @@ function startHandshake(fromKeyboard) {
|
|||
});
|
||||
} else {
|
||||
var nearestAvatar = findNearbyAvatars(true)[0];
|
||||
debug("nearest avatar", nearestAvatar);
|
||||
if (nearestAvatar) {
|
||||
pendingFriendAckFrom = nearestAvatar.avatar;
|
||||
debug("sending friendRequest to", pendingFriendAckFrom);
|
||||
messageSend({
|
||||
key: "friendRequest",
|
||||
id: nearestAvatar.avatar,
|
||||
|
@ -314,14 +311,13 @@ function messageHandler(channel, messageString, senderID) {
|
|||
} catch (e) {
|
||||
debug(e);
|
||||
}
|
||||
debug("message", message);
|
||||
switch (message.key) {
|
||||
case "friendRequest":
|
||||
if (state == STATES.inactive && message.id == MyAvatar.sessionUUID) {
|
||||
debug("setting latestFriendRequestFrom", senderID);
|
||||
latestFriendRequestFrom = senderID;
|
||||
} else if (state == STATES.waiting && !pendingFriendAckFrom) {
|
||||
// you are waiting for a friend request, so send the ack
|
||||
} else if (state == STATES.waiting && (pendingFriendAckFrom == senderID || !pendingFriendAckFrom)) {
|
||||
// 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;
|
||||
messageSend({
|
||||
key: "friendAck",
|
||||
|
@ -436,5 +432,8 @@ Script.scriptEnding.connect(function () {
|
|||
Controller.keyReleaseEvent.disconnect(keyReleaseEvent);
|
||||
debug("disconnecting updateVisualization");
|
||||
Script.update.disconnect(updateVisualization);
|
||||
if (entity) {
|
||||
entity = Entities.deleteEntity(entity);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue