Skip to content

Conversation

@jdetter
Copy link
Collaborator

@jdetter jdetter commented Sep 27, 2023

Description of Changes

  • When you invoke a reducer from the CLI, now OnConnect and OnDisconnect are invoked in the module.

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API
  • This is a change in behavior that may be API breaking

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

@jdetter jdetter changed the title OnConnect/OnDisconnect called from CLI connect/disconnect reducers called when executing reducer from from CLI Sep 27, 2023
Comment on lines 96 to 98
let result = if let Err(e) = module.call_identity_connected_disconnected(caller_identity, true).await {
return Err((StatusCode::NOT_FOUND, format!("{:#}", anyhow::anyhow!(e))).into());
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if/else chain is kinda grody, and I don't think it's necessary. Can this be:

if let Err(e) = module.call_identity_connected_disconnected(caller_identity, true).await {
    // handle error
}
let result = match module.call_reducer(whatever).await {
    // whatever
};

It also seems like the if let Err(e) = foo { return Err(whatever); } could be made into a helper function, something like:

fn with_status_code(code: StatusCode, err: impl std::string::ToString) -> impl Axum::IntoResponse {
    (code, err.to_string())
}

// handling an error
let result = module.call_reducer(caller_identity, None, &reducer, args)
    .map_err(|e| with_status_code(StatusCode::NOT_FOUND, e)?;

}
};
}
Err(e) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call disconnected somewhere in this block?

@jdetter jdetter marked this pull request as ready for review September 28, 2023 21:57
@jdetter jdetter self-assigned this Sep 28, 2023
@jdetter jdetter merged commit cb42225 into master Sep 29, 2023
gefjon added a commit that referenced this pull request Mar 28, 2025
Why were these here?
I did some spelunking, and they were originally added in
#334 ,
without any apparent discussion or justification.
bfops pushed a commit that referenced this pull request Jul 17, 2025
* Some wording changes to the required unity versions

we've had a few people utilize Unity 2021.2, but have a lot of errors/issues in the console. It's best to direct users to 2022.3.32f1 onward.

* Removed recommended verbiage
bfops added a commit that referenced this pull request Jul 17, 2025
## Description of Changes
Missed in
clockworklabs/com.clockworklabs.spacetimedbsdk#333.

We should update the 1.2.1 tag and the `release/latest` branch after
this.

## API

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

Nope

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
bfops added a commit that referenced this pull request Aug 7, 2025
## Description of Changes
Missed in
clockworklabs/com.clockworklabs.spacetimedbsdk#333.

We should update the 1.2.1 tag and the `release/latest` branch after
this.

## API

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

Nope

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants