dongxiaofa6359 2016-12-31 15:55
浏览 51
已采纳

避免同时访问Web应用程序中的共享资源

I have a web application consisting of users having projects , projects belong to to a single user and are access by the URI:root/project/[pid] .

Now I have a middleware to restrict users from accessing each others projects. Although I also have a feature in my web application by which an user may share their projects with other users, so multiple users can access a single shared project.

The problem is I don't want them to access the same project simultaneously , say if project1 is shared by user1 and user2 . URI root/project/project1_id could be accessed by both but not at the same time .

I am currently thinking how I could do this , I have some ideas but wanted to know if there is best or easier way to do this.

I am thinking of altering the project table in the database to have an active flag which would be set to true every time any user accesses the project web page and unset when he/she leaves the webpage or the session ends.

But I have not sure if this would be the best way to go .

I am using laravel as a framework for my web application . So a solution within that framework would be great

  • 写回答

2条回答 默认 最新

  • doutan2456 2017-01-02 15:21
    关注

    I ended up using the below mentioned solution to the problem:

    I added a updated_at timestamp and update_by column in my project table which get update evertime someone updates the project

    In the front end I set up a long poll function which checks the project table every couple of seconds

    If there is a update in project in the past 5 seconds or so by someone other than me I fetched the entire updated project in the front end.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染