kurtextrem / PS2Alerts

Easy overview over PlanetSide2 Alerts in Chrome.
https://chrome.google.com/webstore/detail/planetside-2-alerts/bondapheaemfkkiabfjnhdempfmnikcg
11 stars 0 forks source link

PS2Alerts 3.0 integration #15

Closed Maelstromeous closed 9 years ago

Maelstromeous commented 9 years ago

Hey bud, long time no see.

I've recently updated PS2Alerts to real time, and it'll require done changes on both my and and yours.

I've converted everything to websockets, for real time communication. I'm wondering whether it's possible to have real time updates for the chrome plugin as well?

I've also got a wealth more of information concerning combat, not sure if that's of any use to you.

kurtextrem commented 9 years ago

I've seen the news already. Sounds great!

For some part we can have real time: Exactly when the popup is open. The background page is not constantly open, which means no data is delivered. It refreshes at a minimum of one minute (chrome limit). Which brings us to the following points: a) Does it make sense to use WebSockets when the popup is open and normal ajax as "background" refresh? b) If yes, does it make sense to continue as Popup (aka browser action)? There is an alternative: The plugin as app, which makes it look like a standalone program. c) As app it could work as fully functional companion for PS2. You got killed by someone who looks suspicious? Alt+tab to the app window to look him up.

Maelstromeous commented 9 years ago

It makes miles more sense to convert it to Websockets, as my data structure is designed around real time, and we'd get that AJAX issue again otherwise.

I'm not sure if you much about websockets but they're highly scalable. It hammers the servers much, much less and it allows for two way communication, on top of the benefit of being near instant.

Now, we could do this two ways, either you can make your own server which clients subscribe to, which would be more coding on your part, our we can attempt to have them connect to my disturb directly, then you would only need to do the front-end stuff.

The only limitation is the TCP connections, the initial connection sequence is very light. It's also quite light on bandwidth, considering only messages that are needed are sent.

Maelstromeous commented 9 years ago

Disturb = Server

kurtextrem commented 9 years ago

I thought about it another time: Websockets don't make much sense in the extensions current state. It's used to get alert start notifications (from the bacjground) and not as "I keep it always open"-window. That brings me to the point to reactivate my old PHP API again (+ updating it).

In the future it could make sense to create a standalone App as mentioned in my last comment. Not sure how many people would see a use in it as the recursion tracker provides similar stuff. Time to develop is another point which I don't have currently. Am 03.11.2014 16:55 schrieb "Matthew Cavanagh" notifications@github.com:

It makes miles more sense to convert it to Websockets, as my data structure is designed around real time, and we'd get that AJAX issue again otherwise.

I'm not sure if you much about websockets but they're highly scalable. It hammers the servers much, much less and it allows for two way communication, on top of the benefit of being near instant.

Now, we could do this two ways, either you can make your own server which clients subscribe to, which would be more coding on your part, our we can attempt to have them connect to my disturb directly, then you would only need to do the front-end stuff.

The only limitation is the TCP connections, the initial connection sequence is very light. It's also quite light on bandwidth, considering only messages that are needed are sent.

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-61498778.

Maelstromeous commented 9 years ago

Well whichever works I guess. Just let me know which path you wanna go down and I'll make the data link up. On 4 Nov 2014 10:10, "Jacob Groß" notifications@github.com wrote:

I thought about it another time: Websockets don't make much sense in the extensions current state. It's used to get alert start notifications (from the bacjground) and not as "I keep it always open"-window. That brings me to the point to reactivate my old PHP API again (+ updating it).

In the future it could make sense to create a standalone App as mentioned in my last comment. Not sure how many people would see a use in it as the recursion tracker provides similar stuff. Time to develop is another point which I don't have currently. Am 03.11.2014 16:55 schrieb "Matthew Cavanagh" notifications@github.com:

It makes miles more sense to convert it to Websockets, as my data structure is designed around real time, and we'd get that AJAX issue again otherwise.

I'm not sure if you much about websockets but they're highly scalable. It hammers the servers much, much less and it allows for two way communication, on top of the benefit of being near instant.

Now, we could do this two ways, either you can make your own server which clients subscribe to, which would be more coding on your part, our we can attempt to have them connect to my disturb directly, then you would only need to do the front-end stuff.

The only limitation is the TCP connections, the initial connection sequence is very light. It's also quite light on bandwidth, considering only messages that are needed are sent.

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-61498778.

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-61618173.

kurtextrem commented 9 years ago

Can you prepare an AJAX path? My domain acts like a proxy, fetches every minute and caches.

Maelstromeous commented 9 years ago

I can. What info do you need to send back? On 6 Nov 2014 09:06, "Jacob Groß" notifications@github.com wrote:

Can you prepare an AJAX path? My domain acts like a proxy, fetches every minute and caches.

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-61946443.

kurtextrem commented 9 years ago

I guess that is a bit vague, but can you make it as similar as it was previously?

Maelstromeous commented 9 years ago

Well I'm thinking that we could open up a two way AJAX call. If I send you updates via AJAX, with information on what's changed, you could then pass that info to your clients.

That, in tandem for you polling me for current info, should make it pretty quick to respond. On 6 Nov 2014 09:58, "Jacob Groß" notifications@github.com wrote:

I guess that is a bit vague, but can you make it as similar as it was previously?

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-61953933.

kurtextrem commented 9 years ago

I don't think that would work, think of fresh installations.

Maelstromeous commented 9 years ago

True. In which case I'll try to improve the message that's sent into one message then.

The message I'll send back will contain the following:

1: Current status of all servers, whether they have active alerts or not. 2: Information about any active alert that's currently ongoing, with the latest information about control %s from that alert. 3: If needed, I can provide things such as deaths, kills, tks etc for further statistical info.

Structure will look like this:

{
    currentAlerts: {
        1: null,
        10: null,
        13: null,
        17: null,
        25: {
            123 : { // AlertID ID
                started: 1234556778,
                ends: 1234556779,
                type: 1, // 1, 2, 3 or 4. Indar, Esamir, Amerish and Hossin alerts respectively
                control: {
                    VS: 30,
                    NC: 40,
                    TR: 30
                },
                weblink: "http://ps2alerts.com/Alert/123",
                APIKey: "124567longassapikeylel"
            }
        }
    }
}

Is that ok for you?

kurtextrem commented 9 years ago

Seems good. One request though: Can you add facility status? :) (Or are those alerts gone?) And I heard there is a pumpkin alert... not sure what data it should display then lol

Maelstromeous commented 9 years ago

Is it really needed? All alerts currently are territory based ones, which SOE say there is no current return for facility alerts as of the near future.

kurtextrem commented 9 years ago

Ah okay, sorry. See my edited comment, I'm not really up to date. What about the pumpkin alert? Is there anything special?

Maelstromeous commented 9 years ago

The pumpkin alerts are annoying, SOE don't provide any statistics about the actual pumpkins, therefore I refuse to support them. They're still in the metagame event API if you wanna see them and show them on the plugin.

Theres no real point developing for them however, the event ends on the 10th I think.

kurtextrem commented 9 years ago

Okay then. Thanks for the info! Let's see how fast we can get the extension running again :+1:

Maelstromeous commented 9 years ago

Actually I'm just thinking, what's stopping you using a websocket for your proxy to my server, and then you sending that out when they poll via AJAX to you? It would provide instant updates, and it'll lessen the load on my server too.

Maelstromeous commented 9 years ago

Course, AJAX will be easier for both of us, was wondering if you wanted to try it.

kurtextrem commented 9 years ago

I actually thought about it as well, but I have no experience with using PHP as Websocket client. (Just Server(PHP): websocket server, client/browser(JS): websocket client). Also my domain is just a webspace, I can't anything from the cmd.

Maelstromeous commented 9 years ago

Hey dude,

Sorry it took me so long to get back to you, been real busy with other projects, such as the new Nanite Systems Website (http://nanitesystemscomics.com).

I've updated my websocket API so that you can access it, should you wish. You can see an example of the messages and responses here:

https://gist.github.com/Maelstrome26/075c661dc92556cd769e

Your API key: 276958a9f53c12ecfe716ee3380dd867b9e24e01

That should be enough to connect to with your web server and pass that information to your clients via AJAX calls :-)

Let me know if you have any queries.

kurtextrem commented 9 years ago

Thanks, I always loved these comics, but didn't have the time to watch reddit for new ones. Really sweet!

Do you have the link for the API? I only have the old link.

Maelstromeous commented 9 years ago

Ahh sorry of course.

http://85.159.214.60:1337

Now, I would prefer if you could connect to the Websocket server with your own server, and then AJAX the info out to your chrome clients, rather than putting tons of load on my server again.

If you need help writing up the Websocket script, I can give you a skeleton which you can use?

kurtextrem commented 9 years ago

Thank you. I guess the Websocket script needs to be run from the cmd or with an unlimited execution time? If it is like that, I'm unfortunate, but I can't do that from my webspace. It's not a (dedicated) server. However, catching your API every 1min shouldn't be putting too much pressure, does it? (client <-> my domain (acts as "proxy") <-> your server)

Maelstromeous commented 9 years ago

Hmm... you don't have a linux server to run?

kurtextrem commented 9 years ago

Nope.

Maelstromeous commented 9 years ago

D: Ok, I'll see if I can revive the AJAX calls.

Maelstromeous commented 9 years ago

Oh... actually... we could do the reverse. I could AJAX to your server with updates, which wouldn't be much load on my server, then you can instantly AJAX to your clients based on my input?

kurtextrem commented 9 years ago

I can't call my clients. They call me, but yes, we could do the POST to my server thing if that works for you.

kurtextrem commented 9 years ago

So, what shall we do now? :)

Maelstromeous commented 9 years ago

Hey dude, real sorry I've not got back recently, I've been extremely busy with Planetside Battles etc.

I'm going to try and get the API finished this weekend. Have your requirements changed?

kurtextrem commented 9 years ago

No worries and no, they're still the same.

Maelstromeous commented 9 years ago

Ok so to get this correct, you need the ability to see all active alerts and territory statuses, along with links to the website?

kurtextrem commented 9 years ago

Yep.

kurtextrem commented 9 years ago

Any progress? :)

kurtextrem commented 9 years ago

By the way:

As part of transforming from SOE to Daybreak Games we are changing our domain names. The domains census.soe.com and data.soe.com are going away and the new domain is census.daybreakgames.com. Please reconfigure your apps to replace census.soe.com and data.soe.com with census.daybreakgames.com! The existing census.soe.com and data.soe.com will be turned off on April 30th 2015. We will no longer own the soe domain so we cannot continue to handle requests after April 30th.

Maelstromeous commented 9 years ago

Yeah I noticed that, good they told us at least.

I'm still heavily engaged with Planetside Battles, however the changes I've made will mean that I don't need to be present at server smashes myself any more, and staff will be able to create their own streaming pages too automatically, which reduces my workload significantly.

I'll be spending this 4 day weekend polishing that system off, and will hopefully mean I can get back to PS2Alerts. I've not been giving it the attention it deserves lately :-(

I thank you for your patience though :-) it's just been real busy lately. On 31 Mar 2015 10:23, "Jacob Groß" notifications@github.com wrote:

By the way:

As part of transforming from SOE to Daybreak Games we are changing our domain names. The domains census.soe.com and data.soe.com are going away and the new domain is census.daybreakgames.com. Please reconfigure your apps to replace census.soe.com and data.soe.com with census.daybreakgames.com! The existing census.soe.com and data.soe.com will be turned off on April 30th 2015. We will no longer own the soe domain so we cannot continue to handle requests after April 30th.

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-88011628.

Maelstromeous commented 9 years ago

I've finally got round to starting the API. Sorry it's been taking so long, I had a massive backlog with Planetside Battles that I had to deal with.

I'll give you some docs soon :-)

Maelstromeous commented 9 years ago

Details of what I plan to make available: http://redd.it/346wg7

kurtextrem commented 9 years ago

That sounds good. As last time: it would be the best to include detailed alert information (like what is the goal for example) in the server api so I don't have to make multiple requests.

Also, I have my A level exams currently, which will be over in one month. Once they're done (and the API is done as well) I'll start updating :-) Am 28.04.2015 21:56 schrieb "Matthew Cavanagh" notifications@github.com:

Details of what I plan to make available: http://redd.it/346wg7

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-97187500.

Maelstromeous commented 9 years ago

Hey man,

I've now made the Active Alerts API. Here is a sample:

{
  "1": {
    "status": "inactive"
  },
  "10": {
    "resultID": "6864",
    "instanceID": "5267",
    "world": "10",
    "zone": "2",
    "started": "1430761899", // UNIX timestamp of start of alert
    "endtime": "1430769099", // UNIX timestamp of predicted end of alert
    "type": "1", // I'll be putting these values in my API docs.
    "controlVS": "34", // % control for VS, NC, TR etc
    "controlNC": "38",
    "controlTR": "27",
    "status": "active" // Whether the alert is active according to PS2Alerts or not
  },
  "13": {
    "resultID": "6865",
    "instanceID": "5311",
    "world": "13",
    "zone": "4",
    "started": "1430766041",
    "endtime": "1430773241",
    "type": "4",
    "controlVS": "34",
    "controlNC": "21",
    "controlTR": "44",
    "status": "active"
  },
  "17": {
    "resultID": "6863",
    "instanceID": "5212",
    "world": "17",
    "zone": "8",
    "started": "1430761573",
    "endtime": "1430768773",
    "type": "2",
    "controlVS": "27",
    "controlNC": "27",
    "controlTR": "44",
    "status": "active"
  },
  "19": {
    "status": "inactive"
  },
  "25": {
    "status": "inactive"
  }
}
Maelstromeous commented 9 years ago

oops :P

Maelstromeous commented 9 years ago

I'll PM you a API key to use, I'll write up some documentation later, but it's a pretty simple request.

Heres the format you need to send requests in:

http://api.ps2alerts.com/v1/servers/active/{SERVERID}?apikey={APIKEY}

eg

http://api.ps2alerts.com/v1/servers/active/all?apikey=12345

ServerIDs supported are:

1: Connery
10: Miller
13: Cobalt
17: Emerald
19: Jaeger
25: Briggs
all: All servers returned

I suspect you'll be using the all request :)

kurtextrem commented 9 years ago

Will start working on the extension this weekend or probably one or two weeks later.

Thanks again.

2015-05-04 21:08 GMT+02:00 Matthew Cavanagh notifications@github.com:

I'll PM you a API key to use, I'll write up some documentation later, but it's a pretty simple request.

Heres the format you need to send requests in:

http://api.ps2alerts.com/v1/servers/active/{SERVERID}?apikey={APIKEY}

eg

http://api.ps2alerts.com/v1/servers/active/all?apikey=12345

ServerIDs supported are:

1: Connery 10: Miller 13: Cobalt 17: Emerald 19: Jaeger 25: Briggs all: All servers returned

I suspect you'll be using the all request :)

— Reply to this email directly or view it on GitHub https://github.com/kurtextrem/PS2Alerts/issues/15#issuecomment-98818639.

Maelstromeous commented 9 years ago

All working, good work dude :)