Skip to content

Commit

Permalink
Add in time check for type=Type and type=Category and don't send the …
Browse files Browse the repository at this point in the history
…same data if present
  • Loading branch information
hplato committed Mar 30, 2017
1 parent 311ce73 commit 86b6888
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/json_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,12 @@ sub json_get {
'type' => 'Category',
'members' => ''
};
if ( filter_object( $temp_object, \%args ) ) {
$json_data{objects}{$category} = $temp_object;
# if a time has been supplied, then the client data has been initialized, and we don't need to send it again
# if a category gets added, it won't refresh, but that's rare and this prevents the clients from continually sending data
unless ( $args{time} && $args{time}[0] > 0 ) {
if ( filter_object( $temp_object, \%args ) ) {
$json_data{objects}{$category} = $temp_object;
}
}
}

Expand All @@ -541,8 +545,12 @@ sub json_get {
'type' => 'Type',
'members' => ''
};
if ( filter_object( $temp_object, \%args ) ) {
$json_data{objects}{$type} = $temp_object;
# if a time has been supplied, then the client data has been initialized, and we don't need to send it again
# if a category gets added, it won't refresh, but that's rare and this prevents the clients from continually sending data
unless ( $args{time} && $args{time}[0] > 0 ) {
if ( filter_object( $temp_object, \%args ) ) {
$json_data{objects}{$type} = $temp_object;
}
}
}
}
Expand Down Expand Up @@ -922,7 +930,7 @@ sub json_object_detail {
#To avoid missed changes, since they can happen at the millisecond level, give a second's cushion
#Object has not changed since time, so return undefined
return;
}
}
}

my %json_objects;
Expand Down

0 comments on commit 86b6888

Please sign in to comment.