Closed Maelstromeous closed 10 years ago
Thanks Matthew, I'm looking forward to integrating your API. Unfortunately, I'm in exam season right now and so I don't have time until weekend or holidays. I hope you can understand that and therefore it will take some time to implement. (I'll do my best) Oh and from the first look your API seems like a perfect replacement, it will fit pretty well I think... although I've to warn you: A lot of traffic will come in, because of the 1 min refresh. Is that okay?
Hey Kurtextrem!
I've just finished off a new change to PS2Alerts, which is live alert pages. Essentially what they are is a live history of the alert that's currently in progress.
With the API that I've developed, you should be able to successfully link up these pages from within your App. This would benefit the website because of increased traffic, and it would benefit your plugin as more people would install it. Essentially your plugin would become a "Notifier" and my pages would be the "Log" or "History" of the alerts.
Integrating it should be relatively simple, you should just need to do a AJAX call to my API, where you can define the server you wish to query, and it will return a full link to the page in question.
Heres an example of the API, note the "FullAlertLink" field: http://ps2alerts.com/API/status/10
For more information regarding the Status API, please visit http://ps2alerts.com/API. You can of course ask me any questions you'd like here if you're unsure how to integrate it.
Since I've never developed a chrome extension before, I can't really assist you on that matter, but I can do my best with integration with PS2Alerts! :-)
— Reply to this email directly or view it on GitHubhttps://github.com/kurtextrem/PS2Alerts/issues/3 .
Hey Kurt,
No worries, I know myself how much a stressful time exam time is, I wish you luck with them! There's no rush for this to be done, whenever you have the time.
Since you'll only be executing a very small query the performance hit should be quite low. However, what you can do is that while the alert is active, you don't need to poll for the alert page. You can still use SOEs API to detect whether there's an alert going on or not, and if that status changes, then poll my server for updates on what page to grab.
I'm also looking into websockets and if they can benefit us, as this seems like the kind of thing they're built for, however it looks like it requires some server side implementation and im not sure if it would overload my servers connections.
Websockets won't benefit this extension, as it loads the data in the background (connection is opened, fetched, closed). However, it could benefit your page directly. (auto refresh)
Yup. It's clear I need to research more into them. As mentioned anyway, if you're using my API to find the alert links, the query is tiny and I'll be using a CodeIgniter's caching library soon, so the impact should be fairly minimal.
Kind Regards,
Matt Cavanagh
On 26 May 2014 18:23, Jacob Groß notifications@github.com wrote:
Websockets won't benefit this extension, as it loads the data in the background (connection is opened, fetched, closed). However, it could benefit your page directly. (auto refresh)
— Reply to this email directly or view it on GitHubhttps://github.com/kurtextrem/PS2Alerts/issues/3#issuecomment-44205924 .
I've looked into the API now and it looks pretty well. Still, there is one major flaw which potentially prevents the usage: A ton of AJAX requests are needed to get all the information, if an alert is running. (None: 1 request, All: n+n (=total count of servers and it's detail pages) That's why I'd like to ask, whether it's possible to create an API which returns active alerts directly in the first request. See here: http://kurtextrem.de/PS2/get/data or directly in the source code (https://github.com/kurtextrem/PS2Alerts/blob/master/server/App.class.php#L122).
Thanks for your efforts.
Oh, and on a side-note: Your API outputs JSON, but has the mime type "text/html". Should be "application/json".
No problem, I'll make it for you tonight when I get home from work.
I can also make it return the last record that I have if you wish? I kinda need to do this work anyway as I plan to re-do the real time monitor on my site as it's not working with territory data currently.
I'm also working in implementing caching to the API, so don't worry about the number of requests, it'll literally take milliseconds to serve them along with no queries required :P
Of course, you can return as much as you want :) The caching sounds great.
Changes made. You can now use the link http://ps2alerts.com/API/status. I've added an array called "Actives" which will list all the details regarding the active alerts, along with their last stats record. This is cached every 15 seconds, but I can add a nocache flag so that it's instant. Let me know if this would be useful for you.
I've also added a debugging flag, used like this: REQUEST/?debug=1.
This will format the results into pre tags and print_r the array returned, making it easier to read.
Also changed application type, thanks for spotting it :-)
Thanks, looks great! :) The extension refreshes only every minute (chrome extension background alarm limit), so 15 sec should be fine. One last request, can you add the server online / offline status? Thank you very much. Also: I'm working on the integration already. :)
You mean if the server is up or down? I don't collect that data, although I really should. Let me take a look at it.
Also, are you in a position to update the live copy?
Yep, my extension also shows whether a server is up or not (so to say it also is a maintenance checker). That's why I'd love to have that data as well.
I think so. I need to tweak a few things, but after that the version should be ready for a release(-candidate).
Could you do me a favor, could you include post data called "ref" in your request to the API, and fill it with something meaningful such as "kurtextrem alert monitor", it's just for me to keep track on how often the API is being used a day. Shouldn't affect the speed of the results at all really.
Also, regarding online servers, you're best off using the SOE API, unless you'd like me to cache it and serve it to you?
Added the ref. Yeah, I'd love you to add the server status per server. Alerts can't be running while the server is off, can they? :D
Just doing that now. I'll comment when done.
http://ps2alerts.com/API/serverstatus?debug=1
Remove debug when you're using it :-) Also can you add the ref to that request also? Ta.
API Request is cached for 60 seconds. Let me know if this needs to be less.
Also, just looked over your code, I'm guessing you've not added the code yet to offer a link to the Alert Details page on the PS2Alerts website?
Yes, didn't add that as I want to change the design. I didn't figure out how exactly yet. I'll surely add it. Just wanted to make sure everything is working before adding new stuff. By the way, the API shows a Database error^^
Just looked at the API, no database error for me. Could you take a screenshot when it next happens?
I'll do. It's working fine now. The best errors are the ones which fix themselves. :D If that change can be made easily: Can you add the status to the alerts api (Keeping the one ajax request thing in mind)? Example: Status: INACTIVE | ACTIVE | OFFLINE (so active and inactive = online)
Yup. I'll make the change when I get back from work in 4 hours.
Do you want the INACTIVE / ACTIVE status on the server itself, or the alert?
On the server itself would be best. Thank you :)
I somehow can't figure out which timestamp is the alert start in the "status" API (Actives). Could you explain? Thank you. Also, if no alert is running, could you link to the normal server page? (Like: [FullAlertLink] => http://ps2alerts.com/stats/Cobalt)
Ok I've made the changes, sorry it took a while. I couldn't do it in one field, as it would involve two more queries, which if it's already firing off 5 queries, things are beginning to stack.
Sample of an active alert:
[ServerID] => 25 [LastTimestamp] => 1401616762 [EventID] => 2 [UpdatedTimestamp] => 1401616797 [AlertRef] => 7649 [FullAlertLink] => http://ps2alerts.com/Alert/7649 [ServerStatus] => ONLINE [Status] => ACTIVE [Detail] => stdClass Object ( [type] => Territory [cont] => Amerish [contID] => 6 )
Inactive alert:
[ServerID] => 18 [LastTimestamp] => 1401619203 [EventID] => 2 [UpdatedTimestamp] => 1401612012 [AlertRef] => 7647 [FullAlertLink] => http://ps2alerts.com/Alert/7647 [ServerStatus] => ONLINE [Status] => INACTIVE [Detail] => stdClass Object ( [type] => Territory [cont] => Amerish [contID] => 6 )
Offline Server:
[ServerID] => 18 [LastTimestamp] => 1401619203 [EventID] => 2 [UpdatedTimestamp] => 1401612012 [AlertRef] => 7647 [FullAlertLink] => http://ps2alerts.com/stats/Waterson [ServerStatus] => OFFLINE [Status] => INACTIVE [Detail] => stdClass Object ( [type] => Territory [cont] => Amerish [contID] => 6 )
You'll just have to do a simple IF statement at your end :-)
The extension is ready, will push the new version soon. :) Thanks for your cooperation!
Thanks bud. Let me know if you need anything changing in the future! :-)
Just to let you know, some alerts are being reported back as active although the server is offline. That's an issue my end, no changes are needed at your end, if you've used the OFFLINE status to remove it from the monitor.
I published the new version now. I hope there are no major bugs (I couldn't find any) - as I'm in italy for a week now (holidays) :)
Ooh I likey! Have fun on your holidays!
Hey Kurtextrem!
I've just finished off a new change to PS2Alerts, which is live alert pages. Essentially what they are is a live history of the alert that's currently in progress.
With the API that I've developed, you should be able to successfully link up these pages from within your App. This would benefit the website because of increased traffic, and it would benefit your plugin as more people would install it. Essentially your plugin would become a "Notifier" and my pages would be the "Log" or "History" of the alerts.
Integrating it should be relatively simple, you should just need to do a AJAX call to my API, where you can define the server you wish to query, and it will return a full link to the page in question.
Heres an example of the API, note the "FullAlertLink" field: http://ps2alerts.com/API/status/10. The result you see there is encoded into JSON, so you'll have to decode it first to make any sense of it.
For more information regarding the Status API, please visit http://ps2alerts.com/API. You can of course ask me any questions you'd like here if you're unsure how to integrate it.
Since I've never developed a chrome extension before, I can't really assist you on that matter, but I can do my best with integration with PS2Alerts! :-)