Answer the question
In order to leave comments, you need to log in
How to properly organize WebSocket and Laravel 5?
Hello. I really need an explanation of one problem, I'll try briefly.
I'll start with the task: you need to make search results on websockets. That is, the user entered a request, the browser connected to the server via a websocket, when the next result is found, the server sends it to the browser and the browser displays it. The web socket is needed because the search can take at least half an hour (a very large number of different sources), and I don’t want to use ajax here (so as not to constantly poll the server and not load it), but simply loading the page is completely excluded due to the formulation of the task itself ( long lead time). The websocket event model in general looks very attractive.
Now about the problem. I have read and viewed a lot of materials about the bundle, which is probably the most popular. Node.js is installed, socket.io is loaded into the browser. The browser communicates with node.js. node.js itself communicates with laravel via redis. Laravel broadcasts an event with the name of the channel, it is (apparently) written in redis, and node.js listens to redis, picks up a new event and sends it to all browsers listening to this channel.
But I need to:
a) Pass the search parameters to Laravel from the browser
b) Return the result of processing from Laravel to a specific browser, and not to everyone in a row in general
Point "b" is not disclosed anywhere at all. If the user is not authorized, then it is completely (to me) not clear how laravel will pass something to him, because laravel does not know who exactly requests the result.
I can't find answers to these questions anywhere, and I don't even know where I'm going. Has anyone come across it and can advise?
I will add that I don’t want to throw out Laravel from here. The search functionality is already there. Writing a demon in PHP and somehow putting this functionality there is a dubious matter ...
I will add that somehow calling Laravel from node.js is also not suitable - then you have to wait for Laravel to fully work. In theory, it is necessary to somehow make it so that at the user's request, Lara starts searching, and in the process of searching, right in a huge cycle, throws events outward about new data found.
It is possible that I do not understand how it works at all and whether it can work this way, because. encounter for the first time.
Answer the question
In order to leave comments, you need to log in
the search can last at least half an hour (a very large number of different sources)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question