75 lines
No EOL
1.9 KiB
JavaScript
75 lines
No EOL
1.9 KiB
JavaScript
// checkinClient.js
|
|
//
|
|
// Created by Milad Nazeri on 2018-06-19
|
|
// Expanded on by Robin Wilson 2018-08-28
|
|
//
|
|
// 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 entityID,
|
|
url = "",
|
|
event = null;
|
|
|
|
// Collections
|
|
var userData = {},
|
|
userdataProperties = {};
|
|
|
|
function EnterZoneServer() {
|
|
}
|
|
|
|
EnterZoneServer.prototype = {
|
|
remotelyCallable: [
|
|
"sendInput"
|
|
],
|
|
|
|
preload: function (id) {
|
|
entityID = id;
|
|
userData = Entities.getEntityProperties(entityID, ["userData"]).userData;
|
|
|
|
try {
|
|
// set properties from the userData
|
|
userdataProperties = JSON.parse(userData);
|
|
url = userdataProperties.url;
|
|
event = userdataProperties.event;
|
|
|
|
print("userData is", JSON.stringify(userdataProperties));
|
|
} catch (e) {
|
|
//
|
|
}
|
|
|
|
},
|
|
|
|
sendInput: function (id, params) {
|
|
|
|
var paramString = this.encodeURLParams({
|
|
username: params[0],
|
|
displayName: params[1],
|
|
date: new Date()
|
|
});
|
|
|
|
print("sendInput is", JSON.stringify(paramString));
|
|
|
|
var request = new XMLHttpRequest();
|
|
request.open('GET', url + "?" + paramString);
|
|
request.timeout = 10000;
|
|
request.send();
|
|
},
|
|
|
|
encodeURLParams: function (params) {
|
|
var paramPairs = [];
|
|
for (var key in params) {
|
|
paramPairs.push(key + "=" + params[key]);
|
|
}
|
|
return paramPairs.join("&");
|
|
},
|
|
|
|
unload: function () {
|
|
}
|
|
};
|
|
|
|
return new EnterZoneServer();
|
|
}); |