♠️
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
  1. RACE Protocol
  2. Game Development
  3. Race JS SDK
  4. Advanced Features

Submitting Messages

Using the submitMessage Function

The RACE JS SDK provides the submitMessage function in both the AppClient and SubClient classes to allow players to send chat messages or other communications to the Transactor server. This function takes a single argument, content, which is a string representing the message content.

Here's an example of using the submitMessage function to send a chat message:

// Assuming client is an initialized AppClient or SubClient instance

const messageContent = 'Hello, everyone!';

client.submitMessage(messageContent);

When the client calls this function, the SDK performs the following actions:

  1. Serialization: The message content is serialized into a Message object, which includes the sender's address and the content string.

  2. Encryption: The Message object is encrypted using the Transactor's public key. This ensures that only the Transactor can decrypt and read the message.

  3. Transmission: The encrypted Message object is sent to the Transactor server.

Upon receiving the message, the Transactor decrypts it and then broadcasts it to all connected clients. The clients can then display the message in their chat interfaces or handle it according to the game logic.

By utilizing the submitMessage function, developers can implement chat features or other communication mechanisms within their Race games, allowing players to interact with each other and with the game server in a secure and efficient manner.

PreviousExiting and DetachingNextSub-game Interaction

Last updated 1 year ago

🎲