49 lines
No EOL
1.2 KiB
JavaScript
49 lines
No EOL
1.2 KiB
JavaScript
//
|
|
// avatarCounter.js
|
|
//
|
|
// Created by Rebecca Stankus on 07/09/2018.
|
|
// Copyright 2018 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
(function() {
|
|
var _this;
|
|
|
|
var AvatarCounter = function() {
|
|
_this = this;
|
|
};
|
|
|
|
AvatarCounter.prototype = {
|
|
interval: null,
|
|
|
|
preload: function(entityID) {
|
|
_this.entityID = entityID;
|
|
},
|
|
|
|
enterEntity: function() {
|
|
Messages.subscribe("TriviaChannel");
|
|
Messages.messageReceived.connect(_this.triviaListener);
|
|
},
|
|
|
|
leaveEntity: function() {
|
|
try {
|
|
Messages.messageReceived.disconnect(_this.triviaListener);
|
|
Messages.unsubscribe("TriviaChannel");
|
|
print("UNSUBSCRIBING from triviaChannel");
|
|
} catch (err) {
|
|
print("could not disconnect from messages");
|
|
}
|
|
},
|
|
|
|
unload: function() {
|
|
if (_this.interval) {
|
|
Script.clearInterval(_this.interval);
|
|
}
|
|
}
|
|
};
|
|
|
|
return new AvatarCounter;
|
|
});
|
|
|