OK - I think it's probably time for me to write a short guide as there are a few new features that people have been asking for that I have now built and are working (as far as I can tell).
The first is the
status endpoint.
To use the end point, you need to make a POST request via ajax or similar, (I'm using axios as an example here, but the premise is the same)
Code:
var axois = require('axios');
var payload = {
performers: [
"hot-performer1",
"siswet",
"mycherrycrush"
]
};
axios.post('http://3.16.31.21:7777/api/v1/status/', payload).then((response) => {
console.log(response);
// response will be in the format of:
/*
{
"results": {
"hot-performer1": false,
"siswet": true,
"mycherrycrush": false
}
}
*/
// Where true is online and false is offline.
});
There is a limit of 20 performers per request. Any more than that will simply get ignored.
The second thing I want to explain is the bigger feature that I've just completed. It's still in "beta," as in I haven't worked out all the kinks and the format may change rapidly. I'll keep the thread up to date with things, though.
I've implemented a socket server that published online / offline performers as the database is updated with new information. This happens every minute, so every minute the data about who as come online and who has gone offline is published via websockets. If you've worked with socket.io before then this should be pretty easy to understand. If you haven't, here's some basic code to start you off.
For the mean time, the WebSocket address is "3.16.31.21:7778". Again, this is highly subject to change and I'll update the thread if it does become something different.
Code:
var socket = io('3.16.31.21:7778');
socket.on('tick', function(msg){
console.log(msg);
});
The data that you receive from the server is in the following format:
Code:
{
"total_stored": <INT> // the total number of performers in the database, both online and offline.
"new_performer": <INT> // the number of performers that have come online since the last check that have never been seen before.
"came_online": <INT> // the total number of performers that have come online since the last check.
"went_offline": <INT> // the total number of performers that went offline since the last check.
"continued": <INT> // the number of performers that remained online since the last check.
"total_online": <INT> // total number of performers online.
"net_change": <INT> // the delta of performers since the last check.
"came_online_usernames": <Array<STR>> // a list of usernames of performers that came online.
"went_offline_usernames": <Array<STR>> // a list of usernames of performers that went offline.
}
If for example, you were waiting for a particular performer to come online, then you could write code something akin to:
Code:
var socket = io('3.16.31.21:7778');
socket.on('tick', function(msg){
if(msg.came_online_usernames.indexOf('my-fave-performer') > -1) {
alert('Performer came online!');
}
});
If this doesn't make any sense or you're hoping to have a different example shown, please let me know and I'll see what I can do.