A simplified string that represents an auth object.
The Auth object that was generated from the given authKey.
function joinRoomWithOldAuth(roomId, authKey, playerName, playerAvatar){
Utils.authFromKey(authKey).then((authObj)=>{
Room.join({
id: roomId,
}, {
storage: {
player_name: playerName,
avatar: playerAvatar,
player_auth_key: authKey,
// ...
},
authObj: authObj,
// ...
// other parameters here
// ...
});
}, (error)=>{
console.error("Wrong auth key.");
});
}
Converts a Uint8Array that was read from the backend into a readable ip address string.
The data to be converted
The recovered ip address string.
Calculates the distances to the given GeoLocation geo of all rooms in given roomList and stores them inside each room's dist property.
The location to calculate the distances to.
The room list to update.
void.
Returns the number representation of the given html color string. (rgba representation) This function is mostly intended to be used in renderers and map editors.
undefined.255 to all alpha values by default.)The rgba representation of a color.
An integer that represents the given color.
Compares the bits of value1 and value2 at the exact positions that
are 1 in the given bitMask.
The first value to be compared.
The second value to be compared.
The bit mask that represents which bits to compare.
A boolean whose value is true if all bits that are compared are equal.
Generate and return text content from a stadium object that can be directly written in a .hbs file.
The string(.hbs) representation of the stadium object.
Generates a new player_auth_key along with its companion auth object(authObj) to be used as parameters to the function Room.join. We should store the auth key and use it later if we want to be recognized in Mooball rooms. Any internal error will result in a rejected promise.
A new auth key and auth object.
function joinRoomWithNewAuth(roomId, playerName, playerAvatar){
Utils.generateAuth().then(([authKey, authObj])=>{
Room.join({
id: roomId,
}, {
storage: {
player_name: playerName,
avatar: playerAvatar,
player_auth_key: authKey,
// ...
},
authObj: authObj,
// ...
// other parameters here
// ...
});
}
}
Generates and returns the room id corresponding to the given room token. This function also refreshes the room token and returns the new token.
An object that might have the following keys:
token: string: The room token.proxyAgent: object: A custom proxy agent to use for the connection. This method does not work in browsers. (Default value is null)A Promise that resolves to an object that contains roomId, (roomEndpoint) and newToken keys. The promise is rejected if an error occurs.
Connects to moo-hoo.com, retrieves your location based on IP address using backend's geolocation API and returns it. Might throw errors.
A promise that returns a GeoLocation object that has your location data retrieved from the backend server.
function joinRoomWithNewAuthAndBackendGeo(roomId, playerName, playerAvatar){
Utils.getGeo().then((geo)=>{
Utils.generateAuth().then(([authKey, authObj])=>{
Room.join({
id: roomId,
}, {
storage: {
player_name: playerName,
avatar: playerAvatar,
player_auth_key: authKey,
geo: geo,
// ...
},
authObj: authObj,
// ...
// other parameters here
// ...
});
}
}).catch((ex)=>{
console.error("Error:", ex);
});
}
Connects to moo-hoo.com, retrieves the current room list and returns it.
A promise that returns the current list of open public rooms returned from the moo-hoo.com.
Converts the playerObject.conn values to readable ip address string.
The string to be converted
The converted ip address string.
Returns the numeric representation of the given ip address. Returns null if the input string is ill-formatted.
The ip address to be converted.
An integer for ipv4 string, a BigInt for ipv6 string.
Returns an integer key state value, only to be used with Room.setKeyState.
An integer in the range [0, 31].
Returns the auth string for the numeric representation of it. Returns null if the input number is invalid.
The numeric representation of an auth string to be converted.
An auth string.
Returns the html color string (rgba representation) of the given number. This function is mostly intended to be used in renderers and map editors. Bad inputs will return a bad string output.
A number in the range [0, 16777215].
The rgba representation of the color that was generated from the given number.
Returns the ip address string of a given numeric representation. Returns null if the input number is invalid.
The numeric representation of an ip address to be converted.
A formatted ip string.
Parses the given string or json object as a GeoLocation object and returns it.
OptionalgeoStr: string | objectAn (optionally stringified) object that may have the following keys:
lat: Latitude value.lon: Longitude value.flag: Country code.Optionalfallback: objectAn object whose keys will be used as fallback if the first parameter does not have any of the requested key(s). It should have lat, lon, flag as well.
OptionalretNull: booleanWhether to return null if geoStr is null. Defaults to true.
A GeoLocation object.
Parses a string(.hbs) as a Stadium object.
The string representation of a Stadium object.
The generated Stadium object, or undefined if an error occurs.
Returns a new promise that executes the given promise until msec milliseconds have passed. If timeout is reached, the promise is rejected.
A Promise that has to be executed with a time limit
The time limit
The new promise with time limit.
Generates a new room token from an old room token OR a rcr(recaptcha response) value.
An object that might have the following keys:
token: string: The old room token. (Default value is "")rcr: string: The recaptcha response value received from Google Recaptcha v2 API. (Default value is "")A Promise that resolves to an object that contains code and value keys. code can be 0, 1 or 2. Possible scenarios are as follows:
code = 0; The token value was accepted and value contains the new room token.code = 1; The token value was rejected and value contains the sitekey value that is required by Google Recaptcha v2 API to show recaptcha inside a website.code = 2; An error occurred while sending request or receiving response and value contains the error.Runs a callback function after ticks game ticks.
The function to run.
Number of ticks to wait before running the callback function. Defaults to 1.
void.
Recreates the auth object from the given
authKey. The returned object is only to be used as parameter to the functionRoom.join. Bad inputs or any internal error will result in a rejected promise.