Update socket.io.client.service.js

This commit is contained in:
David Baldwynn 2017-04-20 21:24:53 -07:00 committed by GitHub
parent cc1b0bdf98
commit cecbcf3b90

View file

@ -9,28 +9,6 @@
Socket.$inject = ['$timeout', '$window'];
function Socket($timeout, $window) {
var service = {
connect: connect,
emit: emit,
on: on,
removeListener: removeListener,
socket: null
};
var url = '';
if($window.socketPort && $window.socketUrl){
url = $window.socketUrl + ':' + $window.socketPort;
} else if ($window.socketUrl && !$window.socketUrl){
url = $window.socketUrl;
} else if ($window.socketPort){
url = window.location.protocol+'//'+window.location.hostname + ':' + $window.socketPort;
} else {
url = window.location.protocol+'//'+window.location.hostname;
}
connect(url);
return service;
// Connect to Socket.io server
function connect(url) {
service.socket = io(url, {'transports': ['websocket', 'polling']});
@ -60,5 +38,27 @@
service.socket.removeListener(eventName);
}
}
var service = {
connect: connect,
emit: emit,
on: on,
removeListener: removeListener,
socket: null
};
var url = '';
if($window.socketPort && $window.socketUrl){
url = $window.socketUrl + ':' + $window.socketPort;
} else if ($window.socketUrl && !$window.socketUrl){
url = $window.socketUrl;
} else if ($window.socketPort){
url = window.location.protocol+'//'+window.location.hostname + ':' + $window.socketPort;
} else {
url = window.location.protocol+'//'+window.location.hostname;
}
connect(url);
return service;
}
}());