How to use Autobahn js to connect to the Ratchet websocket server

In order to be able to implement autobahn and websockets on your website you need to implement first of all the Ratchet server. To do that you will have to install a lot of extensions on your server to get it work. But then you need to do the client side part where you will have to use autobahn js in order to connect to the server and hanndle all functions as update the content, remove things or any other functions you need to implement.

To do that you need to add the following code to your website. But of course before that you will need to upload autobahn files to your server.

How to use autobahn

Using the following code you will be able to create all functions you need to update the content:

var conn = new ab.Session('wss://domain.com:your_port',
    function() {
    	 conn._websocket.onclose = function(data){
    	 console.log(data);
    	 alert('Please refresh and try again');
    	 },
        conn._websocket.onmessage = function (data){
         // here comes all your functions
});

This is all the code you need to make it working, but before that you have to make sure the implementation is done and you have no extension missing for your server. Let me know if you need any help with this implementation and I will try to help you to fix the issue. 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x