-2

I'm trying to create a web application with 2 pages video page and picture page. After watch video user will be redirected to picture page The requirements are :

  • Video page show video on lists either sequential or random, total video played will be limited, ex: Video A only able to play 2 times, Video B only able to play 3 times, and so on.. if all limit is reached then limit will be reseted.

  • Picture page show picture corresponding with video

So it's like when user access this web

if user got video A -> got picture A

if user got video B -> got picture B

What i've thought:

*video and picture has same name.

  1. Write video name list,limit, and current played on a txt(TXT_Video).

  2. When user access video page program will check the limit (if current played < limit {...}) in the txt(TXT_Video) recursively to get name of video that will be played.

  3. Program show video on video page then write video name to another txt(TXT_picture).

  4. Program get the picture name from (TXT_picture) and show picture to picture page.

Problem :

My problem is dealing with concurrency :

  • User X got video A but didnt play it.
  • User Y got Video B and play it. Then redirected to Picture B.
  • User X play the video. Then redirected to Picture B which is wrong.

How can i deal with this problem without passing parameter on url?

vintry
  • 301
  • 3
  • 9
  • This question is too broad. There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. – DavidPostill Aug 07 '14 at 08:14

1 Answers1

0

Break down the things you want to show the user into a separate resources, each of which has a unique URL. Use links and redirects to move users around your application.

So, to show users a random video, have a show-video resource that redirects to a randomly selected video resource. Have each video resource redirect to its corresponding picture resource on completion of the video.

To limit video views you will have to record which videos which users have seen how many times. To safely do that the normal technique is to use a database with transactions for accesses. That protects your application from concurrency problems.

You will need for your application to check whether a user is authorized to view a video again before serving the video resource for that video.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
  • the function that call video page and picture page is different. How does function on picture page know which resources to access? – vintry Aug 07 '14 at 08:59