PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/games/heartbeat.php +15 -20 0.9.71.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Games Heartbeat sync (PHP).
3 + * OpenStation — Games Heartbeat sync (PHP).
4 4 *
5 5 * Piggybacks on the WordPress Heartbeat tick — the same channel
6 6 * presence and folder sharing use — to deliver challenge activity
7 7 * to connected users live: a new pending challenge for the
@@ -9,9 +9,9 @@
9 9 *
10 10 * Wire format. Client sends:
11 11 *
12 12 * {
13 - * desktop_mode_games_subscribe: {
13 + * openstation_games_subscribe: {
14 14 * challengesVersion: lastSeenUpdatedAtMs
15 15 * }
16 16 * }
17 17 *
@@ -16,9 +16,9 @@
16 16 * }
17 17 *
18 18 * Server responds:
19 19 *
20 - * desktop_mode_games: {
20 + * openstation_games: {
21 21 * challenges: [ <ChallengeShape> ], // rows involving me,
22 22 * // updated_at_ms > version
23 23 * serverTimeMs: int,
24 24 * truncated: bool
@@ -24,32 +24,29 @@
24 24 * truncated: bool
25 25 * }
26 26 *
27 27 * Version-gated: a quiet tick carries no rows. Truncation kicks in
28 - * past `desktop_mode_games_heartbeat_max_rows` (default 50) — the
28 + * past `openstation_games_heartbeat_max_rows` (default 50) — the
29 29 * client falls back to `GET /games/challenges` for a full resync.
30 30 *
31 - * @package WPDesktopMode
32 - * @since 0.9.6
31 + * @package OpenStation
33 32 */
34 33
35 34 defined( 'ABSPATH' ) || exit;
36 35
37 36 /**
38 - * @since 0.9.6
39 - *
40 37 * @param array $response Pre-filtered response.
41 38 * @param array $data Client-sent payload.
42 39 * @return array
43 40 */
44 -function desktop_mode_games_heartbeat_received( $response, $data ) {
41 +function openstation_games_heartbeat_received( $response, $data ) {
45 42 if ( ! is_array( $response ) ) {
46 43 $response = array();
47 44 }
48 - if ( empty( $data['desktop_mode_games_subscribe'] ) || ! is_array( $data['desktop_mode_games_subscribe'] ) ) {
45 + if ( empty( $data['openstation_games_subscribe'] ) || ! is_array( $data['openstation_games_subscribe'] ) ) {
49 46 return $response;
50 47 }
51 - if ( ! function_exists( 'desktop_mode_is_enabled' ) || ! desktop_mode_is_enabled() ) {
48 + if ( ! function_exists( 'openstation_is_enabled' ) || ! openstation_is_enabled() ) {
52 49 return $response;
53 50 }
54 51
55 52 $user_id = (int) get_current_user_id();
@@ -56,9 +53,9 @@
56 53 if ( $user_id <= 0 ) {
57 54 return $response;
58 55 }
59 56
60 - $sub = $data['desktop_mode_games_subscribe'];
57 + $sub = $data['openstation_games_subscribe'];
61 58 $version = isset( $sub['challengesVersion'] ) ? (int) $sub['challengesVersion'] : 0;
62 59
63 60 /**
64 61 * Filter the per-tick challenge row cap. Past the cap the
@@ -64,24 +61,22 @@
64 61 * Filter the per-tick challenge row cap. Past the cap the
65 62 * payload is flagged `truncated` and the client resyncs over
66 63 * REST.
67 64 *
68 - * @since 0.9.6
69 - *
70 65 * @param int $cap Default 50.
71 66 */
72 - $cap = max( 1, (int) apply_filters( 'desktop_mode_games_heartbeat_max_rows', 50 ) );
67 + $cap = max( 1, (int) apply_filters( 'openstation_games_heartbeat_max_rows', 50 ) );
73 68
74 - $rows = desktop_mode_games_get_challenges_for_user( $user_id, $version, $cap + 1 );
69 + $rows = openstation_games_get_challenges_for_user( $user_id, $version, $cap + 1 );
75 70 $truncated = count( $rows ) > $cap;
76 71 if ( $truncated ) {
77 72 $rows = array_slice( $rows, 0, $cap );
78 73 }
79 74
80 - $response['desktop_mode_games'] = array(
81 - 'challenges' => array_map( 'desktop_mode_games_shape_challenge', $rows ),
82 - 'serverTimeMs' => desktop_mode_games_now_ms(),
75 + $response['openstation_games'] = array(
76 + 'challenges' => array_map( 'openstation_games_shape_challenge', $rows ),
77 + 'serverTimeMs' => openstation_games_now_ms(),
83 78 'truncated' => $truncated,
84 79 );
85 80 return $response;
86 81 }
87 -add_filter( 'heartbeat_received', 'desktop_mode_games_heartbeat_received', 5, 2 );
82 +add_filter( 'heartbeat_received', 'openstation_games_heartbeat_received', 5, 2 );