@@ -6846,22 +6846,27 @@ function TallyArbiter_Delete_Cloud_Key(obj) {
6846
6846
function TallyArbiter_Remove_Cloud_Client ( obj ) {
6847
6847
let ipAddress = null ;
6848
6848
let key = null ;
6849
+ let clientRemoved = false ;
6849
6850
for ( let i = 0 ; i < cloud_clients . length ; i ++ ) {
6850
6851
if ( cloud_clients [ i ] . id === obj . id ) {
6851
6852
//disconnect the cloud client
6852
6853
ipAddress = cloud_clients [ i ] . ipAddress ;
6853
6854
key = cloud_clients [ i ] . key ;
6854
- if ( io . sockets . connected [ cloud_clients [ i ] . socketId ] ) {
6855
+ if ( io . sockets . connected && io . sockets . connected . includes ( cloud_clients [ i ] . socketId ) ) {
6855
6856
io . sockets . connected [ cloud_clients [ i ] . socketId ] . disconnect ( true ) ;
6857
+ clientRemoved = true ;
6856
6858
}
6857
6859
cloud_clients . splice ( i , 1 ) ;
6858
6860
break ;
6859
6861
}
6860
6862
}
6861
6863
6862
- logger ( `Cloud Client Removed: ${ obj . id } ${ ipAddress } ${ key } ` , 'info' ) ;
6863
-
6864
- return { result : 'cloud-client-removed-successfully' } ;
6864
+ if ( clientRemoved ) {
6865
+ logger ( `Cloud Client Removed: ${ obj . id } ${ ipAddress } ${ key } ` , 'info' ) ;
6866
+ return { result : 'cloud-client-removed-successfully' } ;
6867
+ } else {
6868
+ return { result : 'cloud-client-not-removed' , error : 'Cloud client not found.' } ;
6869
+ }
6865
6870
}
6866
6871
6867
6872
function GetSourceBySourceId ( sourceId ) {
@@ -7094,7 +7099,7 @@ function FlashListenerClient(listenerClientId) {
7094
7099
if ( listenerClientObj ) {
7095
7100
if ( listenerClientObj . cloudConnection ) {
7096
7101
let cloudClientSocketId = GetCloudClientById ( listenerClientObj . cloudClientId ) . socketId ;
7097
- if ( io . sockets . connected [ cloudClientSocketId ] ) {
7102
+ if ( io . sockets . connected && io . sockets . connected . includes ( cloudClientSocketId ) ) {
7098
7103
io . sockets . connected [ cloudClientSocketId ] . emit ( 'flash' , listenerClientId ) ;
7099
7104
}
7100
7105
}
@@ -7128,7 +7133,7 @@ function MessageListenerClient(listenerClientId, type, socketid, message) {
7128
7133
if ( listenerClientObj ) {
7129
7134
if ( listenerClientObj . cloudConnection ) {
7130
7135
let cloudClientSocketId = GetCloudClientById ( listenerClientObj . cloudClientId ) . socketId ;
7131
- if ( io . sockets . connected [ cloudClientSocketId ] ) {
7136
+ if ( io . sockets . connected && io . sockets . connected . includes ( cloudClientSocketId ) ) {
7132
7137
io . sockets . connected [ cloudClientSocketId ] . emit ( 'messaging_client' , listenerClientId , type , socketid , message ) ;
7133
7138
}
7134
7139
}
@@ -7173,7 +7178,7 @@ function AddCloudClient(socketId, key, ipAddress, datetimeConnected) {
7173
7178
function DeleteCloudClients ( key ) {
7174
7179
for ( let i = cloud_clients . length - 1 ; i >= 0 ; i -- ) {
7175
7180
if ( cloud_clients [ i ] . key === key ) {
7176
- if ( io . sockets . connected [ cloud_clients [ i ] . socketId ] ) {
7181
+ if ( io . sockets . connected && io . sockets . connected . includes ( cloud_clients [ i ] . socketId ) ) {
7177
7182
io . sockets . connected [ cloud_clients [ i ] . socketId ] . disconnect ( true ) ;
7178
7183
cloud_clients . splice ( i , 1 ) ;
7179
7184
}
0 commit comments