@ -242,6 +242,7 @@ function($rootScope,
var connect = function ( host , port , passwd , ssl , noCompression ) {
var proto = ssl ? 'wss' : 'ws' ;
var url = proto + "://" + host + ":" + port + "/weechat" ;
$log . debug ( 'Connecting to URL: ' , url ) ;
var onopen = function ( ) {
@ -344,9 +345,8 @@ function($rootScope,
$log . info ( "Disconnected from relay" ) ;
failCallbacks ( 'disconnection' ) ;
$rootScope . connected = false ;
if ( $rootScope . waseverconnected ) {
$rootScope . $emit ( 'relayDisconnect' ) ;
} else if ( ssl && evt . code === 1006 ) {
$rootScope . $emit ( 'relayDisconnect' ) ;
if ( ssl && evt . code === 1006 ) {
// A password error doesn't trigger onerror, but certificate issues do. Check time of last error.
if ( typeof $rootScope . lastError !== "undefined" && ( Date . now ( ) - $rootScope . lastError ) < 1000 ) {
// abnormal disconnect by client, most likely ssl error
@ -375,7 +375,8 @@ function($rootScope,
} ;
ngWebsockets . connect ( url ,
try {
ngWebsockets . connect ( url ,
protocol ,
{
'binaryType' : "arraybuffer" ,
@ -384,6 +385,13 @@ function($rootScope,
'onmessage' : onmessage ,
'onerror' : onerror
} ) ;
} catch ( e ) {
$log . debug ( "Websocket caught DOMException:" , e ) ;
$rootScope . lastError = Date . now ( ) ;
$rootScope . errorMessage = true ;
$rootScope . securityError = true ;
$rootScope . $emit ( 'relayDisconnect' ) ;
}
} ;
@ -636,7 +644,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
var activeBuffer = models . getActiveBuffer ( ) ;
$rootScope . pageTitle = activeBuffer . shortName + ' | ' + activeBuffer . title ;
if ( activeBuffer ) {
$rootScope . pageTitle = activeBuffer . shortName + ' | ' + activeBuffer . title ;
}
} ;
$scope . updateFavico = function ( ) {
@ -728,7 +738,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Disabled it until it's fully investigated and fixed
//models.reinitialize();
$rootScope . $emit ( 'notificationChanged' ) ;
$scope . connectbutton = 'Connect' ;
} ) ;
$scope . connectbutton = 'Connect' ;
$scope . showSidebar = true ;
@ -969,10 +981,13 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$scope . connect = function ( ) {
$scope . requestNotificationPermission ( ) ;
$rootScope . sslError = false ;
$rootScope . securityError = false ;
$rootScope . errorMessage = false ;
$scope . connectbutton = 'Connecting ...' ;
connection . connect ( $scope . host , $scope . port , $scope . password , $scope . ssl ) ;
} ;
$scope . disconnect = function ( ) {
$scope . connectbutton = 'Connect' ;
connection . disconnect ( ) ;
} ;
$scope . install = function ( ) {