I have a web app(front-end angular js) that has a socket connection to my express server which works. Now i have to add another socket connection which listen to events from a different server. Can i do this ? Is there any docs i can refer to?
Please refer to socket io docs . Look up io.connect
var server1_socket = io.connect('http://192.168.1.1:3000');
var server2_socket = io.connect('http://192.168.1.1:3001');
server1_socket.on('server1_connection', function (data) {
console.log('Server 1 connection');
});
server2_socket.on('server2_connection', function (data) {
console.log('Server 2 connection');
});
You can you angular-socket-io which exposes a socket factory for instantiating sockets.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.