File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ export type {
110110
111111export type { SsoModule , SsoAccessTokenResponse } from "./modules/sso.types.js" ;
112112
113+ export { RealtimeHandler , type Conn } from "./realtime-handler.js" ;
114+
113115export type {
114116 ConnectorsModule ,
115117 UserConnectorsModule ,
Original file line number Diff line number Diff line change 1+ /**
2+ * Type-only base class for Realtime Handlers.
3+ *
4+ * Import and extend this in your handler files:
5+ * import { RealtimeHandler } from "@base44/sdk";
6+ * export class MyHandler extends RealtimeHandler { ... }
7+ *
8+ * At deploy time the bundler replaces this import with the compiled
9+ * Cloudflare Durable Object implementation — this file provides types only.
10+ */
11+
12+ export interface Conn {
13+ userId : string ;
14+ appId : string ;
15+ instanceId : string ;
16+ send ( data : unknown ) : void ;
17+ reject ( code : number , reason : string ) : void ;
18+ }
19+
20+ export abstract class RealtimeHandler < _State = unknown , Message = unknown > {
21+ abstract handleConnect ( conn : Conn ) : void | Promise < void > ;
22+ abstract handleMessage ( conn : Conn , msg : Message ) : void | Promise < void > ;
23+ abstract handleClose ( conn : Conn ) : void | Promise < void > ;
24+ abstract handleTick ( ) : void | Promise < void > ;
25+
26+ protected broadcast ( _data : unknown ) : void {
27+ throw new Error ( "RealtimeHandler.broadcast() is only available inside a deployed handler" ) ;
28+ }
29+
30+ protected getConnections ( ) : Conn [ ] {
31+ throw new Error ( "RealtimeHandler.getConnections() is only available inside a deployed handler" ) ;
32+ }
33+
34+ protected startLoop ( _ms : number ) : Promise < void > {
35+ throw new Error ( "RealtimeHandler.startLoop() is only available inside a deployed handler" ) ;
36+ }
37+
38+ protected stopLoop ( ) : Promise < void > {
39+ throw new Error ( "RealtimeHandler.stopLoop() is only available inside a deployed handler" ) ;
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments