MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / record

Method record

packages/server/src/api/routes.rs:268–287  ·  view source on GitHub ↗
(&self, udid: &str, client_id: &str, foreground: bool)

Source from the content-addressed store, hash-verified

266
267impl StreamClientForegroundRegistry {
268 pub fn record(&self, udid: &str, client_id: &str, foreground: bool) -> (bool, bool) {
269 let now = Instant::now();
270 let mut clients = self
271 .inner
272 .lock()
273 .unwrap_or_else(|poisoned| poisoned.into_inner());
274 clients.retain(|_, state| {
275 now.duration_since(state.updated_at) <= STREAM_CLIENT_FOREGROUND_TTL
276 });
277 let previous = any_foreground_client_for_udid(&clients, udid);
278 clients.insert(
279 (udid.to_owned(), client_id.to_owned()),
280 StreamClientForegroundState {
281 foreground,
282 updated_at: now,
283 },
284 );
285 let next = any_foreground_client_for_udid(&clients, udid).unwrap_or(true);
286 (next, previous != Some(next))
287 }
288
289 pub fn remove(&self, udid: &str, client_id: &str) -> (bool, bool) {
290 let now = Instant::now();

Callers 3

mainFunction · 0.80

Calls 2

insertMethod · 0.80

Tested by

no test coverage detected