Real time update front end data comming from laravel

蓝咒 提交于 2019-12-11 18:38:33

问题


Orriginal question I'm relatively new to PHP web development and Laravel and looking for a good way to update my front end data real time. I'm developing a simple web based game what can be played with multiple players. When a player did his turn, the data in all players front end need to be updated.

I know there are 2 ways to do this

  1. Websocket(s): Laravel does not support websockets by default what means i need to use a third party service like socket IO. As i just want to run my application on a "normal" web hosting, this is not an option.
  2. push messages:I can also use push message with a service like Pusher or firebase but this option has restrictions when using a free account OR i need to pay after i need more than x resources. This is not what i prefer.

Is there a way to update the front end data without using 3rd party services OR installing a 3rd party application on the server?


Serparated from the previous question, i'm curious if push messages (and the eventually suggested solution) works also for mobile browsers.


Question update: After the comment of Yeeooow i noticed that i needed to ask the question different. Maybe i need to explain my "problem" a bit more and ask for the solution for this.

In my game a player decides when his turn ends and he can trade a card with other players. In both cases the data need to be updated for all players. I use Vue for the front end and Laravel for backend. What is the best practice to achieve my needs?


回答1:


you can use websockets with laravel like Ratchet i had used it with laravel, but you can't use it on shared hosting because you need to import ZMQ and open some ports and that's is not available on shared hosting it is available on VPS or dedicated hosting



来源:https://stackoverflow.com/questions/50949396/real-time-update-front-end-data-comming-from-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!