How to configure my sails app with https socket connection?

68 views Asked by At

I have a sails backend API. And I already have an https connection.

(https://myapp.com/api)

How do I connect to a sails socket with my client side (Android and iOS) having an https connection? I dont have any problem connecting to a non HTTPS server. Hope there is a help.

1

There are 1 answers

0
Arjun Kava On BEST ANSWER

all you have to do is open config/bootstrap.js, and made following changes there

module.exports.bootstrap = function(cb) { 

    // handle connect socket first event executes after logged in
    sails.io.on('connect', function (socket){
        socket.emit("connected",{ data: "here am i!" })
    });

    // handle custom listener for other stuff
    sails.io.on('ping', function (socket){
        socket.emit("pong",{ data: "send to android/ios/web client" })
    });
cb();
};

here you can listen for multiple events as well as you can emit multiple private/broadcast messages as well and also all socket.io listeners will work here