Commit Graph

80 Commits

Author SHA1 Message Date
Kurtis Mullins 809e7d1afb Bump version for release v0.9 (#94)
## Description of Changes

Bumped the version number to 0.9.0 as this was forgotten in the previous
release. Includes all changes to date.

## API

 - [X] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

Not sure but its going out with the latest release. The previous package
was 5 months ago.

## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*
2024-05-22 17:49:34 +01:00
Ingvar Stepanyan 7826f226fb NFC: inline insert/delete update handling (#86)
## Description of Changes

Instead of a separate TableOp enum, and 4 fields to handle insert/delete
metadata in DbOp, use a nullable struct that contains non-nullable
object + bytes pair internally:

- if `insert` is present (non-nullable) and `delete` is nullable, that
naturally indicates insert operation
- if `insert` is nullable and `delete` is not, that's a delete
- if both are non-nullable, it's an update
- if both are null, it's an internal "no change" state

This simplifies and shortens update handling as well as reduces risk of
state getting out of sync - e.g. TableOp saying that the operation is
insert should exist but field containing inserted value being null. Now
nullable struct itself communicates whether there is an insert or not,
without a separate enum.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*
2024-05-14 12:48:52 +01:00
Ingvar Stepanyan 234248db31 Minor refactoring of AuthToken (#84)
## Description of Changes

Initially just fixed the nullability issues / warnings, but in the
process did a few more minor drive-by refactorings.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*
2024-05-14 12:45:22 +01:00
Ingvar Stepanyan ed958663e2 Switch to TaskCompletionSource (#89)
## Description of Changes

There is only one place where we use Channels, and it's to create and await a channel with one element - which is functionally the same as a more precise and low-weight TaskCompletionSource.

Switching also makes the SDK compatible with the widely supported .NET Standard 2.1 subset, which is supported natively in Unity and allows to remove a custom System.Threading.Channels package from Unity SDK dependencies.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*
2024-05-13 17:07:28 +01:00
Ingvar Stepanyan e9c31f16dc Simplify event dispatch in WebSocket (#90)
## Description of Changes

Instead of using custom class hierarchy of messages, we can just use
native C# lambdas stored as Actions.

OnConnectError case can be further simplified by merging two branches
for different exception types into one.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*
2024-05-13 17:05:43 +01:00
Ingvar Stepanyan 56f45a68e0 Add basic CI (#88) 2024-05-13 16:49:57 +01:00
Ingvar Stepanyan 82a7ebd9ce Fix conflict resolution shenanigans (#87) 2024-05-13 16:45:56 +01:00
Ingvar Stepanyan 2f11fbf000 Remove RowUpdate event (#83)
We talked about this for a while, so decided to do this in a separate PR.
2024-05-10 22:41:23 +01:00
Ingvar Stepanyan 0b510f1fd5 NFC: remove unused primaryKeyValue field (#85)
This field is only used in self-assignment, so can be safely removed.
2024-05-09 19:18:18 -04:00
Ingvar Stepanyan 2fd3db4449 Extract common logic from OnMessageProcessComplete (#81)
Minor refactoring that extracts common part of subscription and transaction update handling into a separate function, so that the main logic in `OnMessageProcessComplete` is a bit more straightforward and handles all event types with a sinlge `switch` instead of 3 separate `switch`es.

This is a small no-op step that makes further refactoring and optimisation of said common logic a bit easier.
2024-05-09 15:47:14 +01:00
Ingvar Stepanyan 10f453be4e Merge ByteArrayComparers (#78)
* Merge ByteArrayComparers

Merge various mismatched implementation of byte array comparison/hashing into a single utils class (choosing the most efficient implementation already present).

* Forward hex conversion too

* Use const for Identity & Address sizes
2024-05-08 10:03:18 -04:00
Ingvar Stepanyan 76215b3301 Fix nullability warnings in WebSocket class (#82)
There is a bunch of nullability issues in the project; this PR fixes just the ones in WebSocket + some drive-by fixups and/or syntax simplifications.
2024-04-25 15:43:04 +01:00
Ingvar Stepanyan 596c4a5e5c Make logger a separate SDK setting from client instance (#79)
This allows to:

1. Have a preset logger that is already correctly matching the environment (console vs Unity).
2. Removes the need for explicit `SpacetimeDBClient.CreateInstance(...)` which is particularly awkward to use and easy to forget with singleton as it doesn't return a result as a factory method name could suggest. Instead, `SpacetimeDBClient.instance` is available on first use.
3. Slightly simplifies dependencies between classes, e.g. `ClientCache` doesn't need a circular dependency on `SpacetimeDBClient`, making future maintenance and changes a bit easier.
2024-04-24 17:51:53 +01:00
Ingvar Stepanyan ad07d08919 Set language version to 9 (#80)
This is the last C# version supported by Unity.

While this PR doesn't require almost any C# code changes, I found that limiting the version is helpful for ensuring that I don't accidentally introduce Unity-incompatible code in larger PRs.
2024-04-24 15:34:17 +01:00
Ingvar Stepanyan ed32b089dc Nit: remove unused inserts field (#77) 2024-04-23 13:10:18 +01:00
Ingvar Stepanyan 9be6ceb4ae Add Brotli decompression (#75)
C# client counterpart for https://github.com/clockworklabs/SpacetimeDB/pull/1026.
2024-03-29 11:45:52 -04:00
Phoebe Goldman 2d8b980a52 Remove the rowPk from the client API (#72)
Re: https://github.com/clockworklabs/SpacetimeDB/pull/840

This commit updates the C# SDK to no longer use the `row_pk` field
of the Protobuf client API,
as that field has been removed. (Will have been removed, as of merging.)

Where a table cache was previously keyed on `byte[] rowPk`,
it is now keyed on `byte[] rowBytes`,
where `rowBytes` is the BSATN-encoded bytes of the row.
This means we effectively store two copies of each row in the client cache:
the BSATN serialized format, and the decoded domain type.

An alternate implementation would be to make the table caches be sets of domain types,
discarding the BSATN bytes.
We find this undesirable for several reasons:
- Hashing and equality-comparing `byte[]` is almost certainly more efficient
  than doing the same for domain types.
- Even if hashing and equality-comparing domain types were efficient,
  we would still have to update codegen to emit hashing and equality methods
  for all types in the module_bindings.
  This implementation requires no changes to the module_bindings.
- We already have the BSATN bytes sitting around,
  as they're necessarily part of the message we recieve from the server.
  This change does no additional serialization or deserialization.

In essence, we're trading memory for time and simplicity.
Keeping the BSATN bytes live approximately doubles the table cache's memory usage,
but simplifies the implementation greatly,
and (we suspect) speeds up table cache insertions, deletions and lookups.
2024-02-28 13:56:38 -05:00
John Detter b80f168e51 Added new callback - onBeforeSubscriptionApplied (#71)
* onBeforeSubscriptionApplied

* Small bug fix

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-02-06 14:09:54 -06:00
John Detter ad3d2178c4 Fixed an issue where only one network packet was being processed per (#70)
frame

Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-02-06 12:50:05 -06:00
John Detter 0eebedf80a Upgraded version to 0.8.0 (#66)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-21 09:17:38 -06:00
John Detter a2190a1e70 Workflow for Publishing Nuget Package (#64)
* Committing script for building nuget package

* Script replaced with github action workflow

* On pull requests as well

* Bump version

* Updated build config

* Ready to test

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-21 09:16:32 -06:00
John Detter 4614f81231 v0.7.2-beta Changes (#62)
* Changes merged in from v0.7.1-beta

* Small bug fix from stream

* Updated logo file

* Small bug fix related to OnBeforeDelete callback

* Upgraded version to 0.7.2

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-21 06:08:41 -06:00
John Detter b394a82481 Small updates to 0.7.0 (#61)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-14 03:30:38 -05:00
John Detter 6b8a086c4d Small 0.7.0 Fixes (#60)
* Small update

* Small fix

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-12 12:23:50 -05:00
John Detter 5e4b3bf490 Release v0.7.0-beta (#56)
* One-off query support (#49)

* SpacetimeDBURI argument in place of host and ssl enabled bool (#52)

* SpacetimeDBURI argument in place of host and ssl enabled bool

* Small cleanup

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>

* Add support for client address; re-run `spacetime generate` for quickstart client (#54)

* README.md and License.txt updates (#53)

* Update README.md

* Add license.txt

* Rename

* Add LICENSE.txt with proper case

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>

* Add support for client address; re-run `spacetime generate` for quickstart client

Re: https://github.com/clockworklabs/SpacetimeDB/pull/299

---------

Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com>
Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>

* Making Quickstart Work Again (#57)

* Packaged nuget package, quickstart is now working again

* Reset DBNAME

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>

* OnUnhandledReducerError (#31)

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>

---------

Co-authored-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>
Co-authored-by: SteveBoytsun <100594800+SteveBoytsun@users.noreply.github.com>
Co-authored-by: Steve <steve@codefics.com>
2023-10-12 11:54:57 -05:00
dbrinkmanncw 22676cdc46 README.md and License.txt updates (#53)
* Update README.md

* Add license.txt

* Rename

* Add LICENSE.txt with proper case

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>
2023-10-12 08:28:02 -05:00
dbrinkmanncw af8df9513e Commit quickstart example (#44)
* Commit quickstart example

* GetHashCode fix for Identity.cs

* Remove SDK from quickstart project and add nuget package. Rename spacetime_types folder to module_bindings

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-08 13:50:00 -04:00
dbrinkmanncw 8e34b2741b Update version to 0.6.0 (#48)
* Update version to 0.6.0

* Change PackageId to match other packages

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-02 10:15:37 -04:00
Alessandro Asoni 539f89ba99 Performance improvement for Del/Ins -> Update conversion (#47)
* generate types to SpacetimeDB.Types namespace

* Fix the way we look for Reducer class

* Fix using Identity as Primary Key

* Performance improvement for Del/Ins -> Update conversion

* Fix

* work

* fixes

* Remove accidental commit

* Fix indentation

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-02 10:31:11 +02:00
John Detter 97f75a294a Created PR Template (#38)
* Added PR Template

* Changed headers a bit

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 21:43:09 -05:00
dbrinkmanncw bc12d4e6ac Fix using Identity as Primary Key (#43)
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-01 12:29:37 -04:00
dbrinkmanncw a4a0bb21db generate types to SpacetimeDB.Types namespace (#41)
* generate types to SpacetimeDB.Types namespace

* Fix the way we look for Reducer class

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-08-01 10:22:38 -04:00
Alessandro Asoni 368dca287c Use correct hashcode for identity (#45)
* Use correct hashcode for Identity

* Sneak a tostring fix into this branch

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-07-31 12:12:12 -04:00
John Detter ab1a0c5f19 Fix Typeo (#40) 2023-07-18 13:01:08 -05:00
dbrinkmanncw 46a2c66115 Add optional component to handle saving auth token (#39)
* Add optional component to handle saving auth token to local storage. By default it saves to your user dir

* Fixes for naming collisions

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-07-18 12:52:50 -04:00
dbrinkmanncw cc70102b5a Fix close and improve onConnectError message (#36)
* Fix close not stopping message thread
Add error message to onConnectError
Add more context to "NotAWebSocket" error

* Remove unnecesary while loop

* Clear isclosing flag on Connect

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-07-18 12:33:11 -04:00
John Detter cfc66bbf61 Fixed serialization issue + added jetbrains IDE files to gitignore (#37)
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-07-12 08:55:17 -04:00
Derek Brinkmann b932f129c7 search for reducer type using reflection instead of passing in
nuget package manager files
remove bak file
2023-07-05 17:14:45 -04:00
Derek Brinkmann cef6eb60fa Rename ILogger class to ISpacetimeDBLogger to avoid some annoying naming conflicts. 2023-07-05 08:58:15 -04:00
dbrinkmanncw 16595d8260 Convert Unity SDK into a CSharp SDK with Unity support (#34)
* Initial CSharp SDK Commit

* Compile error fixes

* Minor fixes

---------

Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
2023-06-30 16:11:32 -04:00
SteveBoytsun 4b69a222d5 Custom indexes (#32)
* OnUnhandledReducerError

* Fixed Bitcraft namespace

* Adding support for custom indexes in tables

* Deduped ByteArrayComparer

* Removed onUnhandledReducerError

---------

Co-authored-by: Steve <steve@codefics.com>
2023-06-26 18:10:19 -03:00
SteveBoytsun d70f4b29dd Supporting multiple messages per frame (#29)
Co-authored-by: Steve <steve@codefics.com>
2023-06-19 20:36:22 -03:00
SteveBoytsun 7674913579 Fixed occasional double insert (#30)
Co-authored-by: Steve <steve@codefics.com>
2023-06-19 20:34:48 -03:00
John Detter 7433bbcdd5 Renamed onSubscriptionUpdate to onSubscriptionApplied (#27)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-06-16 12:09:32 -05:00
SteveBoytsun a5e7115bff On before delete (#24)
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Adding OnBeforeDelete event to tables

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2023-06-16 09:32:47 -05:00
SteveBoytsun e6b0639208 Reducer event (#28)
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Adding OnBeforeDelete event to tables

* Renaming ReducerCallInfo to ReducerEvent

* Removed extra onSubscriptionUpdate

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2023-06-16 09:28:17 -05:00
John Detter 942af2efe6 Fixed API (#26)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-06-15 15:05:54 -05:00
SteveBoytsun 39788dff29 Changed guid (#25)
Co-authored-by: Steve <steve@codefics.com>
2023-06-15 11:26:59 -05:00
SteveBoytsun 0ef89cc0da Reducer args in table updates 2 (#23)
* Deserializing reducer args before table updates so they can be accessed from callbacks

* Reducer arguments in table events

* Removed redundant onSubscriptionUpdate

---------

Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-06-15 11:04:17 -05:00
SteveBoytsun 233d1abd88 Deserializing reducer args before table updates so they can be accessed from callbacks (#20)
Co-authored-by: Steve <steve@codefics.com>
2023-06-14 10:13:03 -05:00