MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / Main

Function Main

templates/basic-cs/Program.cs:12–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10string DB_NAME = Environment.GetEnvironmentVariable("SPACETIMEDB_DB_NAME") ?? "my-db";
11
12void 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
42void OnConnected(DbConnection conn, Identity identity, string authToken)
43{

Callers 1

Program.csFile · 0.70

Calls 11

InitMethod · 0.45
BuildMethod · 0.45
OnDisconnectMethod · 0.45
OnConnectErrorMethod · 0.45
OnConnectMethod · 0.45
WithTokenMethod · 0.45
WithDatabaseNameMethod · 0.45
WithUriMethod · 0.45
BuilderMethod · 0.45
FrameTickMethod · 0.45
DisconnectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…