{"action":"created","issue":{"url":"https://api.github.com/repos/voryx/Thruway/issues/186","repository_url":"https://api.github.com/repos/voryx/Thruway","labels_url":"https://api.github.com/repos/voryx/Thruway/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/voryx/Thruway/issues/186/comments","events_url":"https://api.github.com/repos/voryx/Thruway/issues/186/events","html_url":"https://github.com/voryx/Thruway/issues/186","id":140627888,"number":186,"title":"Best practise - using Thruway within php-app to notify users","user":{"login":"TheMiller2015","id":13747267,"avatar_url":"https://avatars.githubusercontent.com/u/13747267?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMiller2015","html_url":"https://github.com/TheMiller2015","followers_url":"https://api.github.com/users/TheMiller2015/followers","following_url":"https://api.github.com/users/TheMiller2015/following{/other_user}","gists_url":"https://api.github.com/users/TheMiller2015/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMiller2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMiller2015/subscriptions","organizations_url":"https://api.github.com/users/TheMiller2015/orgs","repos_url":"https://api.github.com/users/TheMiller2015/repos","events_url":"https://api.github.com/users/TheMiller2015/events{/privacy}","received_events_url":"https://api.github.com/users/TheMiller2015/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-14T10:03:47Z","updated_at":"2016-03-16T18:29:01Z","closed_at":null,"body":"Hello, it's me again ;)\r\n\r\nMaybe it's a dump questions or a dump topic-title, but I don't know how else to call it. I have a general question on how to use Thruway for notifing users within a \"normal\" php-application. It's not a browser game, no collaboration-application, just a CRUD-page. When one user inserts or updates data, the saving-procedure should publish this event via thruway to a channel so that others will be informed.\r\n\r\nI have a working solution, but I don't know, if this is best practise. \r\n\r\nI am running crossbar.io as router and within this router a thruway-client (running all the time) for auth- and session-handling. The user connects via autobahn. Everything fine.\r\n\r\nBut here comes the question:\r\nOn the php-app-side, I thought about a \\Peer\\Client-Class that connects on demand. So when an action like saving data is triggered, the Client would be instantiated, connects to the router and publishs to to specific topic. This solution works, but there are two problems. The first problem is, that the php-script is blocking when the router isn't available/down, even when I add the option that the client shouldn't reconnect (don't know option name by heart). The second \"problem\" is about publishing. The \"publish\"-method can run only once. When I try to publish [\"hello1\"] and lateron [\"hello2\"], it publishs [\"hello1\"] twice. So I extended the class with a function like \"addToPublishQueue($topic, $args, $argsKw=NULL, $options=NULL)\" and at the end of the php-script I call the client's publish with iterates through this \"PublishQueue\" within onSessionStart. That works great, but feels like quick and dirty.\r\n\r\nOther workflows?\r\n* I could use the HTTP-Bridge - but I don't want to. This even feels quick and dirty and is another component in this large set of components (php, thruway, crossbar, redis, sql, nginx, etc.)\r\n* Is it possible (or great idea) to publish from the php-script to redis. The Thruway-Client (which is for auth and session-handling and running all the time) reads/subscribes to this redis-channel and on new data it sends a thruway-publish with the data read from redis(-channel)? \r\n* Does the react-loop help me? I thought, since I am using crossbar, I don't need the react-loop because crossbar doesn't listen to this loop, hence it has its own.\r\n* Or is the solution mentioned above okay?\r\n\r\n**I read a lot of topics/issues on this repository. I think, this is a general question and many developers using thruway would appreciate this discussion. Many thanks in advance!**"},"comment":{"url":"https://api.github.com/repos/voryx/Thruway/issues/comments/197474156","html_url":"https://github.com/voryx/Thruway/issues/186#issuecomment-197474156","issue_url":"https://api.github.com/repos/voryx/Thruway/issues/186","id":197474156,"user":{"login":"TheMiller2015","id":13747267,"avatar_url":"https://avatars.githubusercontent.com/u/13747267?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMiller2015","html_url":"https://github.com/TheMiller2015","followers_url":"https://api.github.com/users/TheMiller2015/followers","following_url":"https://api.github.com/users/TheMiller2015/following{/other_user}","gists_url":"https://api.github.com/users/TheMiller2015/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMiller2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMiller2015/subscriptions","organizations_url":"https://api.github.com/users/TheMiller2015/orgs","repos_url":"https://api.github.com/users/TheMiller2015/repos","events_url":"https://api.github.com/users/TheMiller2015/events{/privacy}","received_events_url":"https://api.github.com/users/TheMiller2015/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T18:29:01Z","updated_at":"2016-03-16T18:29:01Z","body":"Hello @mbonneau and all others,\r\n\r\nI set up the HTTP-Bridge successfully. But since the connection from the web application to the bridge is done via curl or in my case guzzle, it also implements blocking, when the bridge or ws-router isn't available.\r\n\r\nBecause of that, could you give me a hint, how to implement redis? As said above, I have a running php-script that handles all auth and session-data for the websockets. It's loaded with crossbar and runs all the time. Is it possible, that this script subscribes to a redis-channel and the web-app publishes to that channel? This script is based on the Client-Object of thruway.\r\n\r\nI want to eliminate that blocking from the web-app, when ws-router isn't reachable.\r\n\r\nBut despite of the possible blocking, the HTTP-Bridge works very well, easy to set up and to use!\r\n\r\nThank you!"}}