LogoLogo
⚠️ Outdated documentationGo to LatestHomeAPI
SDK 0.7.4
SDK 0.7.4
  • Welcome
  • Overview
    • What is coherence?
    • How does coherence work?
    • Features and Roadmap
    • Rooms and Worlds
    • Requirements
  • Get Started
    • Install coherence
    • Scene setup
    • Prefab setup
    • Build and run
    • Baking and code generation
    • Create a free account
    • Deploy replication server
    • Share builds
  • Authority and communication
    • How authority works
    • Authority transfer
    • Commands / Messages
    • Client messages
    • Server-side and input queues
    • Input prediction and rollback
    • Animations
  • Persistence
    • Overview
    • Configuring persistence
    • Storage
    • Example – A global counter
  • Optimization
    • Overview
    • Simulation frequency
    • Areas of interest
    • World size
    • Level of detail
    • Interpolation
    • Extrapolation
  • Connected entities
    • Overview
    • Entity references
    • Parent-child relationships
    • CoherenceNode
  • Simulators
    • Overview
    • Client vs. simulator logic
    • Build and deploy
    • Simulator load balancing
    • Room Simulators
    • World Simulators
    • Simulator Slugs
    • Testing Simulators Locally
  • Tutorial project
    • Get the Tutorial Project
    • Start Tutorial
      • 1. Transforms
      • 2. Physics
      • 3. Persistence
      • 4. Animation and Variables
      • 5. AI Navigation
      • 6. Network Commands
      • 7. Team based
      • 8. Connected Entities
  • Game Services
    • Game account
    • Key-value store
    • Matchmaking
  • Developer Portal
    • Overview
    • Dashboard
    • Enabling Game Services
    • Configure Rooms
    • Manage Worlds
  • API reference
    • Network SDK
      • CoherenceSync
      • MonoBridge
      • LiveQuery
      • Archetype
      • Sample UI
      • Settings Window
      • Custom Bindings (Advanced)
      • PlayResolver
      • Rooms
      • Worlds
    • Cloud API
      • API tokens and keys
      • Game account
      • Key-value store
      • Matchmaking
    • Replication Server
    • Simulation Server
  • Schema reference
    • Overview
    • Specification
    • Field Settings
    • Archetypes and LOD-ing
  • Resources
    • Downloads
    • SDK Update Guide
    • Video Tutorials
    • Glossary
    • CLI Utilities
    • Simulator CLI arguments
    • Helper Scripts
    • Troubleshooting
  • Community
    • Discord
  • Additional information
    • Pricing
    • SLA
    • Unreal Engine support
    • WebGL
    • Peer-to-Peer (P2P)
    • Known Issues
    • Changelog
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. API reference
  2. Network SDK

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<(Result, RoomData)> CreateRoom(string region,
                string roomName = null,
                int maxClients = 10,
                string[] tags = null,
                Dictionary<string, string> keyValues = null)

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

We can also optionally specify:

  • a room name

  • the maximal 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 operations result and 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)

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.

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

Last updated 3 years ago

Was this helpful?