@@ -17,12 +17,9 @@ import type { Base44Client } from "./client";
1717 */
1818export interface Conn < Send = unknown > {
1919 /** Unique per-connection id (one per socket/tab), the same value the client
20- * receives from `subscribe()`. Use this — not userId — to identify a distinct
21- * client, so multiple tabs of the same user are separate connections. */
20+ * receives from `subscribe()`. Identifies a distinct client, so multiple
21+ * tabs are separate connections. */
2222 id : string ;
23- userId : string ;
24- appId : string ;
25- instanceId : string ;
2623 send ( data : Send ) : void ;
2724 reject ( code : number , reason : string ) : void ;
2825}
@@ -63,12 +60,33 @@ export abstract class Actor<Incoming = unknown, Outgoing = unknown> {
6360 */
6461 handleStart ( ) : void | Promise < void > { }
6562
63+ /**
64+ * Optional handler for scheduled wakes. Runs when a timer armed via
65+ * {@link schedule} comes due, receiving the same `key` that was scheduled.
66+ * The schedule is one-shot: it fires once and is cleared before this runs.
67+ */
68+ protected handleWake ( _key : string ) : void | Promise < void > { }
69+
70+ /**
71+ * Arm a one-shot wake at `at` (epoch ms or a `Date`), identified by `key`.
72+ * When it comes due the platform calls {@link handleWake} with this `key`.
73+ * Scheduling the same `key` again reschedules it.
74+ */
75+ protected schedule ( _key : string , _at : number | Date ) : Promise < void > {
76+ throw new Error ( "Actor.schedule() is only available inside a deployed actor" ) ;
77+ }
78+
79+ /** Cancel a pending wake previously armed with {@link schedule}. */
80+ protected cancelSchedule ( _key : string ) : Promise < void > {
81+ throw new Error ( "Actor.cancelSchedule() is only available inside a deployed actor" ) ;
82+ }
83+
6684 /**
6785 * Managed ticker (opt-in). Override {@link shouldTick} and the platform runs
6886 * {@link handleTick} on a timer of {@link tickIntervalMs} while it returns true,
6987 * and stops (letting the Durable Object hibernate — no compute cost) when it
7088 * returns false. The platform owns scheduling, rescheduling, self-heal, and
71- * error-safety — you don't call { @link startLoop}/{ @link stopLoop } .
89+ * error-safety.
7290 *
7391 * Re-evaluated after every connect/message/close and on every tick, so keep it
7492 * cheap and pure (no async, no side effects). Example: `return this.players >= 2`.
@@ -84,14 +102,6 @@ export abstract class Actor<Incoming = unknown, Outgoing = unknown> {
84102 throw new Error ( "Actor.getConnections() is only available inside a deployed actor" ) ;
85103 }
86104
87- protected startLoop ( _ms : number ) : Promise < void > {
88- throw new Error ( "Actor.startLoop() is only available inside a deployed actor" ) ;
89- }
90-
91- protected stopLoop ( ) : Promise < void > {
92- throw new Error ( "Actor.stopLoop() is only available inside a deployed actor" ) ;
93- }
94-
95105 protected get instanceId ( ) : string {
96106 throw new Error ( "Actor.instanceId is only available inside a deployed actor" ) ;
97107 }
0 commit comments