Update socket.io.client.service.js
This commit is contained in:
parent
cc1b0bdf98
commit
cecbcf3b90
|
@ -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;
|
||||
}
|
||||
}());
|
||||
|
|
Loading…
Reference in a new issue