Skip to content

Commit 4eadeb7

Browse files
update docs
1 parent aeb305b commit 4eadeb7

File tree

18 files changed

+60
-60
lines changed

18 files changed

+60
-60
lines changed

docs/docs/00100-intro/00100-getting-started/00400-key-architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ A view can be written in C# like so:
439439
[SpacetimeDB.View(Name = "MyPlayer", Public = true)]
440440
public static Player? MyPlayer(ViewContext ctx)
441441
{
442-
return ctx.Db.Player.Identity.Find(ctx.Sender) as Player;
442+
return ctx.Db.Player.Identity.Find(ctx.Sender()) as Player;
443443
}
444444
```
445445

docs/docs/00100-intro/00300-tutorials/00100-chat-app.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public static void SetName(ReducerContext ctx, string name)
322322
{
323323
name = ValidateName(name);
324324

325-
if (ctx.Db.User.Identity.Find(ctx.Sender) is User user)
325+
if (ctx.Db.User.Identity.Find(ctx.Sender()) is User user)
326326
{
327327
user.Name = name;
328328
ctx.Db.User.Identity.Update(user);
@@ -411,7 +411,7 @@ public static void SendMessage(ReducerContext ctx, string text)
411411
ctx.Db.Message.Insert(
412412
new Message
413413
{
414-
Sender = ctx.Sender,
414+
Sender = ctx.Sender(),
415415
Text = text,
416416
Sent = ctx.Timestamp,
417417
}
@@ -504,9 +504,9 @@ In `spacetimedb/Lib.cs`, add to the `Module` class:
504504
[Reducer(ReducerKind.ClientConnected)]
505505
public static void ClientConnected(ReducerContext ctx)
506506
{
507-
Log.Info($"Connect {ctx.Sender}");
507+
Log.Info($"Connect {ctx.Sender()}");
508508

509-
if (ctx.Db.User.Identity.Find(ctx.Sender) is User user)
509+
if (ctx.Db.User.Identity.Find(ctx.Sender()) is User user)
510510
{
511511
user.Online = true;
512512
ctx.Db.User.Identity.Update(user);
@@ -517,7 +517,7 @@ public static void ClientConnected(ReducerContext ctx)
517517
new User
518518
{
519519
Name = null,
520-
Identity = ctx.Sender,
520+
Identity = ctx.Sender(),
521521
Online = true,
522522
}
523523
);
@@ -527,7 +527,7 @@ public static void ClientConnected(ReducerContext ctx)
527527
[Reducer(ReducerKind.ClientDisconnected)]
528528
public static void ClientDisconnected(ReducerContext ctx)
529529
{
530-
if (ctx.Db.User.Identity.Find(ctx.Sender) is User user)
530+
if (ctx.Db.User.Identity.Find(ctx.Sender()) is User user)
531531
{
532532
user.Online = false;
533533
ctx.Db.User.Identity.Update(user);

docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00300-part-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Add this function to the `Module` class in `Lib.cs`:
335335
[Reducer]
336336
public static void Debug(ReducerContext ctx)
337337
{
338-
Log.Info($"This reducer was called by {ctx.Sender}");
338+
Log.Info($"This reducer was called by {ctx.Sender()}");
339339
}
340340
```
341341

@@ -444,7 +444,7 @@ Next let's connect our client to our database. Let's start by modifying our `Deb
444444
[Reducer(ReducerKind.ClientConnected)]
445445
public static void Connect(ReducerContext ctx)
446446
{
447-
Log.Info($"{ctx.Sender} just connected.");
447+
Log.Info($"{ctx.Sender()} just connected.");
448448
}
449449
```
450450

docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00400-part-3.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ Next, modify your `Connect` reducer and add a new `Disconnect` reducer below it:
359359
[Reducer(ReducerKind.ClientConnected)]
360360
public static void Connect(ReducerContext ctx)
361361
{
362-
var player = ctx.Db.logged_out_player.identity.Find(ctx.Sender);
362+
var player = ctx.Db.logged_out_player.identity.Find(ctx.Sender());
363363
if (player != null)
364364
{
365365
ctx.Db.player.Insert(player.Value);
@@ -369,7 +369,7 @@ public static void Connect(ReducerContext ctx)
369369
{
370370
ctx.Db.player.Insert(new Player
371371
{
372-
identity = ctx.Sender,
372+
identity = ctx.Sender(),
373373
name = "",
374374
});
375375
}
@@ -378,7 +378,7 @@ public static void Connect(ReducerContext ctx)
378378
[Reducer(ReducerKind.ClientDisconnected)]
379379
public static void Disconnect(ReducerContext ctx)
380380
{
381-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
381+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
382382
ctx.Db.logged_out_player.Insert(player);
383383
ctx.Db.player.identity.Delete(player.identity);
384384
}
@@ -457,7 +457,7 @@ const int START_PLAYER_MASS = 15;
457457
public static void EnterGame(ReducerContext ctx, string name)
458458
{
459459
Log.Info($"Creating player with name {name}");
460-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
460+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
461461
player.name = name;
462462
ctx.Db.player.identity.Update(player);
463463
SpawnPlayerInitialCircle(ctx, player.player_id);
@@ -579,7 +579,7 @@ Let's also modify our `disconnect` reducer to remove the circles from the arena
579579
[Reducer(ReducerKind.ClientDisconnected)]
580580
public static void Disconnect(ReducerContext ctx)
581581
{
582-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
582+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
583583
// Remove any circles from the arena
584584
foreach (var circle in ctx.Db.circle.player_id.Filter(player.player_id))
585585
{

docs/docs/00100-intro/00300-tutorials/00300-unity-tutorial/00500-part-4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Next, add the following reducer to the `Module` class of your `Lib.cs` file.
4949
[Reducer]
5050
public static void UpdatePlayerInput(ReducerContext ctx, DbVector2 direction)
5151
{
52-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
52+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
5353
foreach (var c in ctx.Db.circle.player_id.Filter(player.player_id))
5454
{
5555
var circle = c;
@@ -60,7 +60,7 @@ public static void UpdatePlayerInput(ReducerContext ctx, DbVector2 direction)
6060
}
6161
```
6262

63-
This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the `ctx.Sender` value is not set by the client. Instead `ctx.Sender` is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called.
63+
This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the `ctx.Sender()` value is not set by the client. Instead `ctx.Sender()` is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called.
6464

6565
</TabItem>
6666
<TabItem value="rust" label="Rust" >

docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00300-part-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Add this function to the `Module` class in `Lib.cs`:
333333
[Reducer]
334334
public static void Debug(ReducerContext ctx)
335335
{
336-
Log.Info($"This reducer was called by {ctx.Sender}");
336+
Log.Info($"This reducer was called by {ctx.Sender()}");
337337
}
338338
```
339339

@@ -440,7 +440,7 @@ Next let's connect our client to our database. Let's start by modifying our `Deb
440440
[Reducer(ReducerKind.ClientConnected)]
441441
public static void Connect(ReducerContext ctx)
442442
{
443-
Log.Info($"{ctx.Sender} just connected.");
443+
Log.Info($"{ctx.Sender()} just connected.");
444444
}
445445
```
446446

docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00400-part-3.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Next, modify your `Connect` reducer and add a new `Disconnect` reducer below it:
352352
[Reducer(ReducerKind.ClientConnected)]
353353
public static void Connect(ReducerContext ctx)
354354
{
355-
var player = ctx.Db.logged_out_player.identity.Find(ctx.Sender);
355+
var player = ctx.Db.logged_out_player.identity.Find(ctx.Sender());
356356
if (player != null)
357357
{
358358
ctx.Db.player.Insert(player.Value);
@@ -362,7 +362,7 @@ public static void Connect(ReducerContext ctx)
362362
{
363363
ctx.Db.player.Insert(new Player
364364
{
365-
identity = ctx.Sender,
365+
identity = ctx.Sender(),
366366
name = "",
367367
});
368368
}
@@ -371,7 +371,7 @@ public static void Connect(ReducerContext ctx)
371371
[Reducer(ReducerKind.ClientDisconnected)]
372372
public static void Disconnect(ReducerContext ctx)
373373
{
374-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
374+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
375375
ctx.Db.logged_out_player.Insert(player);
376376
ctx.Db.player.identity.Delete(player.identity);
377377
}
@@ -446,7 +446,7 @@ const int START_PLAYER_MASS = 15;
446446
public static void EnterGame(ReducerContext ctx, string name)
447447
{
448448
Log.Info($"Creating player with name {name}");
449-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
449+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
450450
player.name = name;
451451
ctx.Db.player.identity.Update(player);
452452
SpawnPlayerInitialCircle(ctx, player.player_id);
@@ -566,7 +566,7 @@ Let's also modify our `disconnect` reducer to remove the circles from the arena
566566
[Reducer(ReducerKind.ClientDisconnected)]
567567
public static void Disconnect(ReducerContext ctx)
568568
{
569-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
569+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
570570
// Remove any circles from the arena
571571
foreach (var circle in ctx.Db.circle.player_id.Filter(player.player_id))
572572
{

docs/docs/00100-intro/00300-tutorials/00400-unreal-tutorial/00500-part-4.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Next, add the following reducer to the `Module` class of your `Lib.cs` file.
5050
[Reducer]
5151
public static void UpdatePlayerInput(ReducerContext ctx, DbVector2 direction)
5252
{
53-
var player = ctx.Db.player.identity.Find(ctx.Sender) ?? throw new Exception("Player not found");
53+
var player = ctx.Db.player.identity.Find(ctx.Sender()) ?? throw new Exception("Player not found");
5454
foreach (var c in ctx.Db.circle.player_id.Filter(player.player_id))
5555
{
5656
var circle = c;
@@ -61,7 +61,7 @@ public static void UpdatePlayerInput(ReducerContext ctx, DbVector2 direction)
6161
}
6262
```
6363

64-
This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the `ctx.Sender` value is not set by the client. Instead `ctx.Sender` is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called.
64+
This is a simple reducer that takes the movement input from the client and applies them to all circles that that player controls. Note that it is not possible for a player to move another player's circles using this reducer, because the `ctx.Sender()` value is not set by the client. Instead `ctx.Sender()` is set by SpacetimeDB after it has authenticated that sender. You can rest assured that the caller has been authenticated as that player by the time this reducer is called.
6565
</TabItem>
6666
<TabItem value="rust" label="Rust">
6767
Let's start by building out a simple math library to help us do collision calculations. Create a new `math.rs` file in the `blackholio/spacetimedb/src` directory and add the following contents. Let's also move the `DbVector2` type from `lib.rs` into this file.

docs/docs/00200-core-concepts/00100-databases/00500-cheat-sheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ using SpacetimeDB;
440440
[SpacetimeDB.View(Public = true)]
441441
public static Player? MyPlayer(ViewContext ctx)
442442
{
443-
return ctx.Db.Player.Identity.Find(ctx.Sender);
443+
return ctx.Db.Player.Identity.Find(ctx.Sender());
444444
}
445445

446446
// Return multiple rows
@@ -493,7 +493,7 @@ ctx.identity // Module's identity
493493

494494
```csharp
495495
ctx.Db // Database access
496-
ctx.Sender // Identity of caller
496+
ctx.Sender() // Identity of caller
497497
ctx.ConnectionId // ConnectionId?
498498
ctx.Timestamp // Timestamp
499499
ctx.Identity // Module's identity

docs/docs/00200-core-concepts/00200-functions/00300-reducers/00400-reducer-context.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static partial class Module
145145
public static void UpdateScore(ReducerContext ctx, uint newScore)
146146
{
147147
// Get the caller's identity
148-
Identity caller = ctx.Sender;
148+
Identity caller = ctx.Sender();
149149

150150
// Find and update their player record
151151
if (ctx.Db.Player.Identity.Find(caller) is Player player)
@@ -262,7 +262,7 @@ public static partial class Module
262262
public static void SendReminder(ReducerContext ctx, ScheduledTask task)
263263
{
264264
// Only allow the scheduler (module identity) to call this
265-
if (ctx.Sender != ctx.Identity)
265+
if (ctx.Sender() != ctx.Identity)
266266
{
267267
throw new Exception("This reducer can only be called by the scheduler");
268268
}

0 commit comments

Comments
 (0)