()
| 10 | string DB_NAME = Environment.GetEnvironmentVariable("SPACETIMEDB_DB_NAME") ?? "my-db"; |
| 11 | |
| 12 | void Main() |
| 13 | { |
| 14 | // Initialize the AuthToken module |
| 15 | AuthToken.Init(".spacetime_csharp"); |
| 16 | |
| 17 | // Build and connect to the database |
| 18 | var conn = DbConnection.Builder() |
| 19 | .WithUri(HOST) |
| 20 | .WithDatabaseName(DB_NAME) |
| 21 | .WithToken(AuthToken.Token) |
| 22 | .OnConnect(OnConnected) |
| 23 | .OnConnectError(OnConnectError) |
| 24 | .OnDisconnect(OnDisconnected) |
| 25 | .Build(); |
| 26 | |
| 27 | // Keep the connection alive and process updates |
| 28 | try |
| 29 | { |
| 30 | while (true) |
| 31 | { |
| 32 | conn.FrameTick(); |
| 33 | Thread.Sleep(100); |
| 34 | } |
| 35 | } |
| 36 | finally |
| 37 | { |
| 38 | conn.Disconnect(); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void OnConnected(DbConnection conn, Identity identity, string authToken) |
| 43 | { |
no test coverage detected
searching dependent graphs…