I'm searching for help with my websocket problem. I have built a simple HTML5 websocket to connect between my AngularJS-Site (websocket connects through simple JS) and my PHP-Server. The connection works as well, and also sending and recieving data works as well. The reason, why I need a websocket is: I have a diferent REST-Service (PHP) at the same server, which also communicates with the AngularJS-Site. So the REST-Service changes data at a Database. Now, when I kick an action from the AngularJS-Site (create a new user for example), the REST-Service creates a job in a joblist, and the job will be performed from any other service (not relevant), and after some seconds, the service will give a sign to the REST-Service, if the job is done. The job will be set to done (in the database). Now, at this point as the job is set to done, i need to send a request from the REST-Service to the PHP Websocket, ant the Websocket should send a message to the angularJS-Site. I know, i could polling through Angular-JS, but that would create too big traffic, beacuse many users will use that system at the same time. Sorry for my bad explanation (and also for my bad english - i'm german ;)). My simple question: Is there any possibility to send a request from the PHP REST-Service to the websocket, so the websocket will notify my angular: The job is done. Is that simple request possible, or have I to create a PHP Client which refreshes over and over the database to check, if the job is done and send then to the angular through the websocket? Any other ideas? Thanks for your help! Edit: Maybe as said some code would be good :). There's only some standart-HTML5 websocket, but maybe it would help: JS (in angulars config-method):
Thats the PHP-Websocket (found on internet):
I don't think, the REST-Service is relevant. Edit 2 I think, the only solution for me (after you said, a simple request is not possible) is to create a seperate class (php) which communicates with the websocket. It will open a connection to send, that the job is done, and close it after all. That should work for me, not that graceful, but should work. Thanks for help! |