Simplest Push Approach

60 views
Skip to first unread message

fsa...@gmail.com

unread,
Oct 29, 2015, 11:01:41 AM10/29/15
to Ratchet
Hi, I'm pretty new to Rachet/PHP - but have used websockets with Java.  I'd like to get a little advice on the simplest design for a small project (its for me only).  I have a single device that will be connecting to a local webpage (written with PHP backend).  I want to be able to "push" messages to the browser from a few external scripts (some in python, some shell scripts). 

My thought was to have a Rachet server running on port 8080 alongside the http server.  The JS in the client would connect to Rachet, Rachet would also receive messages (http gets) on port 8080 (or another port) process them and send the appropriate message back over the WS connection.  Problem is I'm not sure how to have PHP/Rachet receive the http messages and the WS connections.  Any tips?

Bl...@kleinhansgroup.com

unread,
Nov 12, 2015, 1:49:22 PM11/12/15
to Ratchet, fsa...@gmail.com

Hey, I am also fairly new to Ratchet and web sockets in general. I'm currently updating my site to get away from all of the ugly AJAX calls I was sending back and forth. I learned a lot from the http://socketo.me/docs/hello-world page. What I have been doing is I copied the structure of the hello world example but instead of just sending strings I am sending JSON objects. On all of my objects I have a 'type' variable that I use to differentiate between things like a chat message and a status update. Now I don't know if this is the simplest design but it works for me.

Hope this helps,
Blake

Mahesh Bhanushali

unread,
Nov 14, 2015, 1:51:10 AM11/14/15
to Ratchet, fsa...@gmail.com


On Thursday, 29 October 2015 20:31:41 UTC+5:30, fsa...@gmail.com wrote:
Hi, I'm pretty new to Rachet/PHP - but have used websockets with Java.  I'd like to get a little advice on the simplest design for a small project (its for me only).  I have a single device that will be connecting to a local webpage (written with PHP backend).  I want to be able to "push" messages to the browser from a few external scripts (some in python, some shell scripts). 

My thought was to have a Rachet server running on port 8080 alongside the http server.  The JS in the client would connect to Rachet, Rachet would also receive messages (http gets) on port 8080 (or another port) process them and send the appropriate message back over the WS connection.  Problem is I'm not sure how to have PHP/Rachet receive the http messages and the WS connections.  Any tips?



Follow this link http://socketo.me/docs/hello-world,  and you need to install some dependencies to run socket server 
Reply all
Reply to author
Forward
0 new messages