LogoLogo
⚠️ Outdated documentationGo to LatestHomeAPI
SDK 0.10
SDK 0.10
  • Welcome
  • Overview
    • What is coherence?
    • How does coherence work?
    • Rooms and Worlds
    • Features and Roadmap
    • Release Notes
    • Known Issues and Troubleshooting
  • Learning coherence
    • First Steps tutorial
      • 1. Basic syncing
        • 1.2. Animation parameters
        • 1.3. Sending commands
      • 2. Physics / Authority transfer
      • 3. Areas of interest
      • 4. Parenting entities
      • 5. Complex hierarchies
      • 6. Persistence
    • How to network...
      • Racing
      • Turn-based
      • First-Person Shooter
      • MMO
      • Fighting
  • Get started
    • Installation
    • Scene Setup
      • Sample UI
    • Prefab Setup: CoherenceSync
    • Local Development
      • Tips and Recommendations
    • coherence Cloud
      • Create a Free Account
      • Deploy a Replication Server
      • Share Builds
  • coherence SDK for Unity
    • Components
      • CoherenceSync
      • CoherenceMonoBridge
      • CoherenceLiveQuery
      • CoherenceTagQuery
      • Order of execution
    • Networking State Changes
      • Messaging with Commands
      • Hierarchies & Child Objects
        • Child GameObjects
        • Child CoherenceSyncs
        • Deep Child CoherenceSyncs
      • Animations
      • CoherenceSync References
      • [Sync] and [Command] Attributes
      • [OnValueSynced] Attribute
      • Supported Types
      • Player Name (Sample UI)
    • Baking (Code Generation)
    • Authority
      • Authority transfer
      • Server-authoritative setup
    • Lifetime
      • Persistence
      • Example – a global counter
    • Optimization
      • Simulation Frequency
      • Areas of Interest
      • Level of Detail (LOD)
    • Interpolation
    • Settings
    • Simulation Frame
    • Replication Server
    • Simulators
      • Scripting: Client vs Simulator
      • Local Development
      • World Simulators
      • Room Simulators
      • Simulator Slugs
      • Multi-Room Simulators
      • Build and Publish
      • Command-line arguments
      • Load Balancing
      • Network Connectivity
    • Client Connections
    • Rollback Networking Support
    • Floating Origin
    • CLI
  • coherence API
    • Worlds
    • Rooms
    • PlayResolver
    • DescriptorProvider
  • Developer Portal
    • Overview
    • Dashboard
    • Worlds
    • Rooms
    • Game Services
      • Account
      • Key-Value Store
      • API
        • Game account
        • Key-value store
  • Schema explained
    • Overview
    • Specification
    • Field settings
    • Archetypes
  • Additional resources
    • Community
    • SDK Upgrade Guide
    • Video Tutorials
    • Quick Samples
    • Continuous Integration
    • Unreal Engine Support
    • WebGL Support
    • Peer-to-Peer Support (P2P)
    • Pricing
    • SLA
    • Glossary
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. coherence API

Rooms

Rooms API

Rooms functionality can be accessed through the PlayResolver which includes all the methods needed to use rooms.

Regions

To manage Rooms we must first decide which region we are working with.

async Task<(IReadOnlyList<string>, bool)> FetchRegions()

FetchRegions in PlayResolver.cs allows us to fetch the regions available for our project. This task returns a list of regions (as strings) and a boolean that indicates if the operation was successful.

async Task<string> FetchLocalRegions()

FetchLocalRegions in PlayResolver.cs returns the local region string for a local running Rooms Server, or null if the operation is un-successful (if the Server isn't running for example).

Every other Rooms API will require a region string that indicates the relevant region for the operation so these strings should not be changed before using them for other operations.

The RoomsConnectDialog populates a dropdown with the region strings returned by both of these methods directly for easy selection.

These methods also call EnsurePlayConnection which initializes the needed mechanisms in the PlayResolver if necessary. EnsurePlayConnection can also be called directly for initialization.

Room management

After we have the available regions we can start managing Rooms, for instance:

async Task<RoomData> CreateRoom(string region, RoomCreationOptions options = null)

CreateRoom in PlayResolver.cs allows us to create a Room in the region we send it.

the RoomCreationOptions is used to optionally specify:

  • a Room name

  • the maximum number of Clients allowed for the Room

  • a list of tags for Room filtering and other uses

  • a key-value collection for the Room

This task returns the RoomData for the created Room assuming the operation was successful.

async Task<IReadOnlyList<RoomData>> FetchRooms(string region, string[] tags = null)

FetchRooms in PlayResolver.cs allows us to search for available Rooms in a region. We can also optionally specify tags for filtering the Rooms.

This task returns a list of RoomData objects for the Rooms available for our specifications.

void JoinRoom(IClient client, RoomData room, bool isSimulator = false)

JoinRoom in PlayResolver.cs connects the client that we pass to the method to the Room we pass to the method. This RoomData object can be either the one we get back from CreateRoom or one of the ones we got from FetchRooms.

When joining a Room, the method is optionally supplied if the connecting Client is a Simulator, as well.

The RoomsConnectDialog demonstrates both of these cases in CreateRoom when called with true for autoJoin and in JoinRoom respectively.

RemoveRoom in PlayResolver.cs allows us to close a Room. The uniqueID can be either the one we get back from CreateRoom or one of the ones we got from FetchRooms, but roomToken (Room's Secret) is only returned by CreateRoom.

async Task RemoveRoom(string region, ulong uniqueID, string roomToken)

Last updated 2 years ago

Was this helpful?