mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Update socket events to match socket.io 1.0.
This commit is contained in:
parent
984c45b183
commit
2e18778d1c
1 changed files with 14 additions and 26 deletions
|
@ -13,12 +13,6 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
|
|||
})
|
||||
})
|
||||
|
||||
socket.on('connecting', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'connecting'
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'disconnect'
|
||||
|
@ -26,16 +20,23 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
|
|||
hasFailedOnce = true
|
||||
})
|
||||
|
||||
socket.on('connect_failed', function () {
|
||||
socket.on('error', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'connect_failed'
|
||||
scope.socketState = 'error'
|
||||
})
|
||||
hasFailedOnce = true
|
||||
})
|
||||
|
||||
socket.on('error', function () {
|
||||
socket.on('connect_error', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'error'
|
||||
scope.socketState = 'connect_error'
|
||||
})
|
||||
hasFailedOnce = true
|
||||
})
|
||||
|
||||
socket.on('reconnect_error', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'reconnect_error'
|
||||
})
|
||||
hasFailedOnce = true
|
||||
})
|
||||
|
@ -54,18 +55,9 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
|
|||
hasFailedOnce = true
|
||||
})
|
||||
|
||||
socket.on('reconnecting', function () {
|
||||
scope.$apply(function () {
|
||||
scope.socketState = 'reconnecting'
|
||||
})
|
||||
hasFailedOnce = true
|
||||
})
|
||||
|
||||
scope.$watch('socketState', function (newValue, oldValue) {
|
||||
if (newValue) {
|
||||
if (newValue === 'connecting' && oldValue) {
|
||||
growl.info('<h4>WebSocket</h4>' + $filter('translate')(gettext('Connecting...')), {ttl: 1000})
|
||||
} else if (newValue === 'connect' && oldValue === 'connecting') {
|
||||
if (newValue === 'connect') {
|
||||
if (hasFailedOnce) {
|
||||
growl.success('<h4>WebSocket</h4>' + $filter('translate')(gettext('Connected successfully.')) + '<refresh-page></refresh-page>', {ttl: 2000})
|
||||
}
|
||||
|
@ -74,9 +66,8 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
|
|||
case 'disconnect':
|
||||
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Disconnected.<br />Socket connection was lost, try again reloading the page.')), {ttl: -1})
|
||||
break;
|
||||
case 'connect_failed':
|
||||
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Error while connecting.')), {ttl: -1})
|
||||
break;
|
||||
case 'connect_error':
|
||||
case 'connect_error':
|
||||
case 'error':
|
||||
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Error.'), {ttl: -1}))
|
||||
break;
|
||||
|
@ -86,9 +77,6 @@ module.exports = function SocketStateDirectiveFactory(socket, growl, gettext, $f
|
|||
case 'reconnect':
|
||||
growl.success('<h4>WebSocket</h4>' + $filter('translate')(gettext('Reconnected successfully.')), {ttl: -1})
|
||||
break;
|
||||
case 'reconnecting':
|
||||
growl.error('<h4>WebSocket</h4>' + $filter('translate')(gettext('Reconnecting...')) + '<refresh-page></refresh-page>', {ttl: -1})
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue