Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(starter-game-template): Add ability to listen to transaction receipts from Nakama #2

Merged
merged 4 commits into from
Aug 15, 2023

Conversation

jerargus
Copy link
Contributor

Implement a mechanism for client to subscribe to transaction receipts.

A single match is created inside of Nakama. Clients can join the match. All transaction receipts will be pushed to all members of the match.

Transactions are fetched from Cardinal in a background process. If no clients are listening to transaction receipts (i.e. no clients have joined the match), transaction receipts will be dropped on the floor.

Also in this PR is a barebones js client that will listen for transaction receipts and print them to the screen.

Problems with this implementation:

  1. All receipts are sent to all clients. Ideally, clients will only receive transactions that they initiated.
  2. There is only 1 match. It's not clear what performance bottlenecks we'll encounter when a large number of players join that singleton match. Ideally matches will be dynamically created as clients subscribe and unsubscribe to transaction receipts.
  3. Nakama's documentation warns against sending too much data too frequently (https://heroiclabs.com/docs/nakama/concepts/multiplayer/authoritative/#send-data-messages) -- tl;dr: They want implements to limit broadcasted messages to 1000 bytes per message and 1 message per client per tick (This is a Nakama tick, not a Cardinal tick).

Testing PR can be done by:

  1. running Cardinal/Nakama normally with mage start
  2. running npm install the node main.js from the jsclient directory
  3. sending transactions to Nakama via the API Explorer.

jsclient/yarn-error.log Outdated Show resolved Hide resolved
nakama/match.go Show resolved Hide resolved
nakama/match.go Show resolved Hide resolved
nakama/dispatcher.go Outdated Show resolved Hide resolved
jsclient/main.mjs Outdated Show resolved Hide resolved
nakama/cardinal.go Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

utACK

@jerargus jerargus merged commit a4337bc into main Aug 15, 2023
2 checks passed
@namrapatel namrapatel deleted the jer/stream-transactions branch November 1, 2023 23:31
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.

4 participants