I’m currently trying to host my own WebSocket server using Ratchet http://socketo.me/docs/push.
The problem is that I can’t find a good tutorial that shows me how I can host this on a subdomain. So hopefully someone can help me here.
My plan:
I already have a basic auth secured subdomain called ws.my-domain.de
. Now I want to run Ratchet on my subdomain to provide this as a service for my main domain and all my subdomains.
At my main domain my-domain.de
I’ve WordPress running so this is where I want to use my own WebSocket first via the client side tutorial from the page I’ve posted above:
<script src="https://gist.githubusercontent.com/cboden/fcae978cfc016d506639c5241f94e772/raw/e974ce895df527c83b8e010124a034cfcf6c9f4b/autobahn.js"></script>
<script>
var conn = new ab.Session('ws://ws.my-domain.de',
function() {
conn.subscribe('kittensCategory', function(topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
});
},
function() {
console.warn('WebSocket connection closed');
},
{'skipSubprotocolCheck': true}
);
</script>
So can please someone show me the steps I need to do? I’m completely new with this. I know how to use it on the client side, but I don’t know how to provide it as a service and then use it in PHP (WordPress).