]>
git.r.bdr.sh - rbdr/sorting-hat-renderer/blob - lib/services/data.js
4 kSocketLocation: 'ws://localhost:1987',
14 internals
.socket
= new WebSocket(internals
.kSocketLocation
);
15 internals
.socket
.addEventListener('message', (data
) => {
17 Object
.assign(internals
.data
, JSON
.parse(data
.data
));
23 * The data structure representing the sorting hat data
25 * @typedef tSortingHatData
27 * @param {number} state the current state: 0 for waiting, 1 for
28 * polling, 2 for cool down.
29 * @param {string} [winner] the winner after polling, might be null if
30 * no winner is detected
31 * @param {Object.<string,tRunningAverages>} runningAverages the running averages for
32 * the different categories, used to render the waves
36 * The running averages, including the current sum and count
38 * @typedef tRunningAverages
40 * @param {number} sum the current total
41 * @param {number} count the number of samples
42 * @param {number} average the average (sum / count)
46 * The main data service, connects to a socket and updates the internal
54 * Returns the internal data structure, intended to be used as the data
55 * property in vue components
57 * @memberof DataService
59 * @return tSortingHatData
63 if (!internals
.socket
) {
64 internals
.initSocket();
67 return internals
.data
;