Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/docs/00200-core-concepts/00600-clients/00300-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ The token is sent to the server during connection and validates your identity. S

:::danger[Critical: C#, Unity, and Unreal Users]

In C# (including Unity) and Unreal Engine, you **must** manually advance the connection to process incoming messages. The connection does not process messages automatically!
In C# (including Unity), you **must** manually advance the connection to process incoming messages. In Unreal Engine, you must either manually advance the connection or enable automatic ticking. If the connection is not advanced, it will not process messages.

Call `DbConnection.FrameTick()` in your game loop or update method:
Call `FrameTick()` in your game loop or update method:

<Tabs groupId="client-language" queryString>
<TabItem value="csharp" label="C#">
Expand All @@ -200,7 +200,7 @@ while (running)
<TabItem value="unreal" label="Unreal">

```cpp
// In your Actor's Tick() method
// Option 1: call FrameTick() from your Actor's Tick() method
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
Expand All @@ -210,6 +210,10 @@ void AMyActor::Tick(float DeltaTime)
Conn->FrameTick();
}
}

// Option 2: enable automatic ticking once after building the connection
Conn = Builder->Build();
Conn->SetAutoTicking(true);
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ A connection to a remote database is represented by the `UDbConnection` class. T
| Name | Description |
| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [Connect to a database](#connect-to-a-database) | Construct a UDbConnection instance. |
| [Advance the connection](#advance-the-connection-and-process-messages) | The connection processes messages automatically via WebSocket callbacks. |
| [Advance the connection](#advance-the-connection-and-process-messages) | Process queued messages with `FrameTick` or automatic ticking. |
| [Access tables and reducers](#access-tables-and-reducers) | Access the client cache, request reducer invocations, and register callbacks. |

### Connect to a database
Expand Down Expand Up @@ -186,7 +186,50 @@ Finalize configuration and open the connection. This creates a WebSocket connect

### Advance the connection and process messages

The Unreal SDK processes messages automatically via WebSocket callbacks and with UDbConnection which ultimately inherits from FTickableGameObject. No manual polling or advancement is required. Events are dispatched through the registered delegates.
The Unreal SDK queues network messages and applies them to the generated client cache on tick. If you do not arrange for the connection to tick, table callbacks, reducer callbacks, and subscription callbacks will not be dispatched.

You can either call `FrameTick()` yourself from an Actor or component tick, or enable the SDK's automatic ticker once after building the connection:

```cpp
void AGameManager::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

if (Conn && Conn->IsActive())
{
Conn->FrameTick();
}
}
```

```cpp
Conn = Builder->Build();
Conn->SetAutoTicking(true);
```

#### Method `FrameTick`

```cpp
class UDbConnection
{
UFUNCTION(BlueprintCallable, Category = "SpacetimeDB")
void FrameTick();
};
```

Process any queued server messages and dispatch the corresponding callbacks. Call this regularly from game-thread code if you manage ticking yourself.

#### Method `SetAutoTicking`

```cpp
class UDbConnection
{
UFUNCTION(BlueprintCallable, Category = "SpacetimeDB")
void SetAutoTicking(bool bAutoTick);
};
```

Enable or disable the SDK's automatic ticker. When enabled, the connection registers with Unreal's core ticker and calls `FrameTick()` for you.

### Access tables and reducers

Expand Down
Loading