♠️
RACE Protocol
NFT PresaleDiscord
  • ❤️Official Docs & Links
  • ⏳Progress Overview
  • RACE Protocol
    • 🏗️System Architecture
      • Components
      • On-chain Accounts
      • Synchronization
      • Randomization
      • Payment
    • 🎲Game Development
      • Game Handler
      • Effect
      • Event Handling
      • Race API
        • Arweave Integration
      • Race JS SDK
        • Installation and Setup
        • Key Components
          • AppClient
          • SubClient
          • Events
          • Game Context
          • Decryption Cache
        • Advanced Features
          • Getting Revealed Knowledge
          • Exiting and Detaching
          • Submitting Messages
          • Sub-game Interaction
        • Best Practices
        • API Reference
        • Troubleshooting
    • 🧪Testing
      • Race Test Kit
      • Unit Testing
      • Integration Testing
      • Additional Considerations
    • 🧱Modules & Features
      • Encryption Methods
      • Command-line Tools
      • Configuration Options
      • Blockchain Transport Implementations
    • 📃Smart Contract
      • Solana Program
    • 🔦Examples and Use Cases
      • Draw Card Game
      • Raffle Game
      • Other Examples
  • RACE Games
    • ♠️RACE Poker app
      • 🎮Start playing in minutes
        • 💰Cash and sit-n-go
        • 🏆Tournaments
      • 🎨Workshop
        • 🏆Create cash games
        • 🏨Create tourneys
      • 💡Concept introduction
      • 🏗️System architecture
      • 👾Game Flow
      • 🎲Cards shuffling
      • ☎️Communication
      • 🔐Key sharing/decryption
      • 💱Cash flow structure
    • ⚡Solfast
      • 🎲Game modes
  • RACE RESEARCH
    • 👾No-Code Development
      • Brainstorming
      • Implementation Approach
      • Project Status
    • 0️⃣Zero-Knowledge Proofs
      • Brainstorming
      • Integration steps
        • Verifiable Randomness Generation
        • Private Game State Updates
        • Verifiable Settlements
        • Private Player Actions
      • Project Status
    • 🛡️Security Audit Report
      • Executive summary
        • Introduction to Race Protocol
        • Audit Methodology
      • Findings
        • Smart Contract Security
        • WebAssembly Security
        • Client-side Security (Race SDK)
        • Server-side Security
        • Randomization and Encryption
        • On-chain Account Management
        • Synchronization Mechanisms
        • Payment Handling
      • Recommendations
      • Conclusion
  • RACE DAO
    • 😎About
    • 🫂Community
    • 🖼️NFT Collection [!]
Powered by GitBook
On this page
  • exit and detach Functions
  • Difference and Appropriate Usage
  1. RACE Protocol
  2. Game Development
  3. Race JS SDK
  4. Advanced Features

Exiting and Detaching

exit and detach Functions

The RACE JS SDK provides two functions for ending a player's participation in a Race game:

  • exit(): This function allows a player to exit the game gracefully. It sends an ExitGame instruction to the Transactor, which triggers the settlement process for that player. This means that the player's winnings or losses are calculated and distributed, and their stake is returned or forfeited according to the game rules. By default, the exit function also disconnects the client from the Transactor server.

  • detach(): This function simply disconnects the client from the Transactor server without initiating the exit process. This can be useful if the player wants to temporarily disconnect but intends to rejoin the game later.

Difference and Appropriate Usage

The key difference between exit and detach lies in their effect on the player's participation in the game:

  • Exiting: When a player exits, they are effectively leaving the game and cannot rejoin the same game session. Their assets are settled, and the game state is updated to reflect their departure. This is the appropriate action when a player wants to permanently leave the game and finalize their winnings or losses.

  • Detaching: When a player detaches, they are only disconnecting from the Transactor server but remain a participant in the game. Their stake remains in the game's stake account, and they can potentially rejoin the game later by reconnecting to the Transactor. This is useful for scenarios where a player may need to temporarily disconnect due to network issues or other reasons but intends to resume playing later.

Here's a summary of when to use each function:

  • Use exit() when the player wants to permanently leave the game and finalize their settlements.

  • Use detach() when the player wants to temporarily disconnect but intends to rejoin the game later.

It's important to note that the game rules may impose restrictions on when players can exit or rejoin a game. Developers should clearly communicate these rules to players through the game UI and ensure that the SDK functions are used appropriately within the game flow.

PreviousGetting Revealed KnowledgeNextSubmitting Messages

Last updated 1 year ago

🎲