You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/c-sharp/index.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ static partial class Module
42
42
{
43
43
// We can skip (or explicitly set to zero) auto-incremented fields when creating new rows.
44
44
varperson=newPerson { Name=name, Age=age };
45
+
45
46
// `Insert()` method is auto-generated and will insert the given row into the table.
46
47
person.Insert();
47
48
// After insertion, the auto-incremented fields will be populated with their actual values.
@@ -211,8 +212,10 @@ public partial struct Person
211
212
212
213
// Finds a row in the table with the given value in the `Id` column and returns it, or `null` if no such row exists.
213
214
publicstaticPerson? FindById(intid);
215
+
214
216
// Deletes a row in the table with the given value in the `Id` column and returns `true` if the row was found and deleted, or `false` if no such row exists.
215
217
publicstaticboolDeleteById(intid);
218
+
216
219
// Updates a row in the table with the given value in the `Id` column and returns `true` if the row was found and updated, or `false` if no such row exists.
Copy file name to clipboardExpand all lines: docs/modules/c-sharp/quickstart.md
+24-5Lines changed: 24 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,18 @@ If you haven't already, start by [installing SpacetimeDB](/install). This will i
16
16
17
17
## Install .NET 8
18
18
19
-
Next we need to [install .NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) so that we can build and publish our module. .NET 8.0 is the earliest to have the `wasi-experimental` workload that we rely on.
19
+
Next we need to [install .NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) so that we can build and publish our module.
20
+
21
+
You may already have .NET 8 and can be checked:
22
+
```bash
23
+
dotnet --list-sdks
24
+
```
25
+
26
+
.NET 8.0 is the earliest to have the `wasi-experimental` workload that we rely on, but requires manual activation:
27
+
28
+
```bash
29
+
dotnet workload install wasi-experimental
30
+
```
20
31
21
32
## Project structure
22
33
@@ -35,7 +46,11 @@ spacetime init --lang csharp server
35
46
36
47
## Declare imports
37
48
38
-
`spacetime init` should have pre-populated `server/Lib.cs` with a trivial module. Clear it out, so we can write a module that's still pretty simple: a bare-bones chat server.
49
+
`spacetime init` generated a few files:
50
+
51
+
1. Open `server/StdbModule.csproj` to generate a .sln file for intellisense/validation support.
52
+
2. Open `server/Lib.cs`, a trivial module.
53
+
3. Clear it out, so we can write a new module that's still pretty simple: a bare-bones chat server.
39
54
40
55
To the top of `server/Lib.cs`, add some imports we'll be using:
41
56
@@ -235,7 +250,7 @@ public static void OnDisconnect(DbEventArgs dbEventArgs)
235
250
else
236
251
{
237
252
// User does not exist, log warning
238
-
Log($"Warning: No user found for disconnected client.");
253
+
Log("Warning: No user found for disconnected client.");
239
254
}
240
255
}
241
256
```
@@ -250,12 +265,16 @@ From the `quickstart-chat` directory, run:
250
265
spacetime publish --project-path server <module-name>
251
266
```
252
267
268
+
```bash
269
+
npm i wasm-opt -g
270
+
```
271
+
253
272
## Call Reducers
254
273
255
274
You can use the CLI (command line interface) to run reducers. The arguments to the reducer are passed in JSON format.
You've just set up your first database in SpacetimeDB! The next step would be to create a client module that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quick start guide for your client language of choice: [Rust](/docs/languages/rust/rust-sdk-quickstart-guide), [C#](/docs/languages/csharp/csharp-sdk-quickstart-guide), [TypeScript](/docs/languages/typescript/typescript-sdk-quickstart-guide) or [Python](/docs/languages/python/python-sdk-quickstart-guide).
290
309
291
-
If you are planning to use SpacetimeDB with the Unity3d game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1) or check out our example game, [BitcraftMini](/docs/unity/part-3).
310
+
If you are planning to use SpacetimeDB with the Unity game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1) or check out our example game, [BitcraftMini](/docs/unity/part-3).
Copy file name to clipboardExpand all lines: docs/modules/rust/quickstart.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -269,4 +269,4 @@ You can find the full code for this module [in the SpacetimeDB module examples](
269
269
270
270
You've just set up your first database in SpacetimeDB! The next step would be to create a client module that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quickstart guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), [TypeScript](/docs/sdks/typescript/quickstart) or [Python](/docs/sdks/python/quickstart).
271
271
272
-
If you are planning to use SpacetimeDB with the Unity3d game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1) or check out our example game, [BitcraftMini](/docs/unity/part-3).
272
+
If you are planning to use SpacetimeDB with the Unity game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1) or check out our example game, [BitcraftMini](/docs/unity/part-3).
Copy file name to clipboardExpand all lines: docs/sdks/c-sharp/quickstart.md
+41-27Lines changed: 41 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# C# Client SDK Quick Start
2
2
3
-
In this guide we'll show you how to get up and running with a simple SpacetimDB app with a client written in C#.
3
+
In this guide we'll show you how to get up and running with a simple SpacetimeDB app with a client written in C#.
4
4
5
-
We'll implement a command-line client for the module created in our Rust or C# Module Quickstart guides. Make sure you follow one of these guides before you start on this one.
5
+
We'll implement a command-line client for the module created in our [Rust](../../modules/rust/quickstart.md) or [C# Module](../../modules/c-sharp/quickstart.md) Quickstart guides. Ensure you followed one of these guides before continuing.
6
6
7
7
## Project structure
8
8
@@ -12,7 +12,7 @@ Enter the directory `quickstart-chat` you created in the [Rust Module Quickstart
12
12
cd quickstart-chat
13
13
```
14
14
15
-
Within it, create a new C# console application project called `client` using either Visual Studio or the .NET CLI:
15
+
Within it, create a new C# console application project called `client` using either Visual Studio, Rider or the .NET CLI:
16
16
17
17
```bash
18
18
dotnet new console -o client
@@ -22,7 +22,7 @@ Open the project in your IDE of choice.
22
22
23
23
## Add the NuGet package for the C# SpacetimeDB SDK
24
24
25
-
Add the `SpacetimeDB.ClientSDK`[NuGet package](https://www.nuget.org/packages/spacetimedbsdk) using Visual Studio NuGet package manager or via the .NET CLI
25
+
Add the `SpacetimeDB.ClientSDK`[NuGet package](https://www.nuget.org/packages/spacetimedbsdk) using Visual Studio or Rider _NuGet Package Manager_or via the .NET CLI:
26
26
27
27
```bash
28
28
dotnet add package SpacetimeDB.ClientSDK
@@ -39,7 +39,7 @@ mkdir -p client/module_bindings
39
39
spacetime generate --lang csharp --out-dir client/module_bindings --project-path server
40
40
```
41
41
42
-
Take a look inside `client/module_bindings`. The CLI should have generated five files:
42
+
Take a look inside `client/module_bindings`. The CLI should have generated five files under `module_bindings`:
43
43
44
44
```
45
45
module_bindings
@@ -65,8 +65,10 @@ We will also need to create some global variables that will be explained when we
65
65
```csharp
66
66
// our local client SpacetimeDB identity
67
67
Identity?local_identity=null;
68
+
68
69
// declare a thread safe queue to store commands in format (command, args)
@@ -75,10 +77,10 @@ CancellationTokenSource cancel_token = new CancellationTokenSource();
75
77
76
78
We'll work outside-in, first defining our `Main` function at a high level, then implementing each behavior it needs. We need `Main` to do several things:
77
79
78
-
1. Initialize the AuthToken module, which loads and stores our authentication token to/from local storage.
79
-
2. Create the SpacetimeDBClient instance.
80
+
1. Initialize the `AuthToken` module, which loads and stores our authentication token to/from local storage.
81
+
2. Create the `SpacetimeDBClient` instance.
80
82
3. Register callbacks on any events we want to handle. These will print to standard output messages received from the database and updates about users' names and online statuses.
81
-
4. Start our processing thread, which connects to the SpacetimeDB module, updates the SpacetimeDB client and processes commands that come in from the input loop running in the main thread.
83
+
4. Start our processing thread which connects to the SpacetimeDB module, updates the SpacetimeDB client and processes commands that come in from the input loop running in the main thread.
82
84
5. Start the input loop, which reads commands from standard input and sends them to the processing thread.
83
85
6. When the input loop exits, stop the processing thread and wait for it to exit.
Congratulations! You've built a simple chat app using SpacetimeDB. You can look at the C# SDK Reference for more information about the client SDK. If you are interested in developing in the Unity3d game engine, check out our Unity3d Comprehensive Tutorial and BitcraftMini game example.
438
+
Congratulations! You've built a simple chat app using SpacetimeDB. You can look at the C# SDK Reference for more information about the client SDK. If you are interested in developing in the Unity game engine, check out our Unity3d Comprehensive Tutorial and BitcraftMini game example.
0 commit comments