PinionTech / pinion-adverts-gmod

Pinion Adverts for Garry's Mod
2 stars 2 forks source link

Modify duration based on data returned from adback API #5

Closed davidbanham closed 11 years ago

davidbanham commented 11 years ago

http://adback.pinion.gg/duration/:steamID Return values: 404 - No data available for that steamID. Expected behaviour, query again in 3 seconds. 200 - Set wait duration to Int contained in response body, unless that would cause duration to be longer than maximum specified by the server admin. Example: 404 - http://adback.pinion.gg/duration/wat 200 - http://adback.pinion.gg/duration/debug

azuisleet commented 11 years ago

I want to make sure I understand this one clearly:

davidbanham commented 11 years ago

The server admin need only set a maximum view duration. The user story is "I am happy for my users to be forced to wait n seconds, but no longer. If it becomes apparent that we're finished showing them content before that, they should be allowed to pass immediately."

Pseudocode:

maxDuration = 25
function trapContinue ->
  if connectionTimer > maxDuration then continue()
  else return null
http.get AdBackUrl + steamID, (returnVal) ->
  if returnVal.status == 404 then tryAgain(3)
  else if returnVal.status == 200
    maxDuration = returnVal.body if returnVal.body < maxDuration
azuisleet commented 11 years ago

Alright one more question: Is this duration something I get before showing the MOTD, or do I get the value after the MOTD is shown to the player, and then adjust the viewing duration?

davidbanham commented 11 years ago

The data is only available after the ad has started playing in the MOTD. So yes, the duration needs to be adjusted.

azuisleet commented 11 years ago

This logic is implemented.