LogoLogo
HomeOnline DashboardAPIDiscordForums
SDK 1.7 Preview
SDK 1.7 Preview
  • Welcome
  • Overview
    • Features
    • Roadmap
  • Getting started
    • Get the Unity SDK
    • Setup a project
      • 1. Scene setup
      • 2. Prefab setup
      • 3. Test your game locally
        • Local testing using builds
        • Local testing via Unity's Multiplayer Play Mode
        • Local testing via ParrelSync
      • 4. Test in the cloud
        • Deploy a Replication Server
        • Share builds
    • How to... ?
    • Single-player to multiplayer
    • Video tutorials
    • Samples and tutorials
      • Package samples
      • Sample Connection UIs
      • First Steps tutorial
        • 1. Basic syncing
          • 1.1 Animation parameters
          • 1.2 Sending commands
        • 2. Physics / Authority transfer
        • 3. Areas of interest
        • 4. Parenting entities
        • 5. Complex hierarchies
        • 6. Persistence
      • Campfire project
        • Game mechanics
        • Leveraging object pooling
        • Remote interactions: Chairs
        • Remote interactions: Trees
        • A unique object with complex state
        • Custom instantiation and destruction
        • Running a server-side NPC
        • Playing audio and particles
        • A simple text chat
      • Beginner's guide to networking
    • Troubleshooting
  • Manual
    • Unity Components
      • CoherenceSync
      • CoherenceBridge
      • CoherenceLiveQuery
      • CoherenceTagQuery
      • CoherenceGlobalQuery
      • CoherenceInput
      • CoherenceNode
      • PrefabSyncGroup
      • Order of execution
    • Networking state changes
      • Instantiate and Destroy Objects
      • Supported types
      • Messaging with Commands
      • Syncing child GameObjects
      • Animation
      • CoherenceSync references
      • [Sync] and [Command] Attributes
      • [OnValueSynced] Attribute
      • Creating your own syncable member
      • Custom Component Actions
      • Rigid Bodies
      • Interpolation
    • Authority
      • Authority transfer
      • Server-authoritative setup
    • Lifetime
      • Persistence
      • Uniqueness
      • Example: A global counter
    • Parenting network entities
      • Direct children CoherenceSyncs
      • Deeply-nested CoherenceSyncs
      • Nesting Prefabs at Edit time
    • Asset management
      • Instantiating from CoherenceSyncConfig
      • Instantiate via
      • Load via
    • Scene management
    • Multiple Connections within a Game Instance
    • Baking (code generation)
      • Conditional compilation
    • Replication Server
      • Rooms and Worlds
      • Replication Server API
    • Simulators (Servers)
      • Scripting: Client vs Simulator
      • Run local Simulators
      • World Simulators
      • Room Simulators
      • Advanced Simulator Authority
      • Simulator slugs
      • Build and Deploy
      • Command-line arguments
    • Client Connections
    • Optimization
      • Areas of Interest
      • Level of Detail (LOD)
      • Profiling
      • Simulation Frequency
    • Project Settings
    • Advanced topics
      • Big worlds
        • World Origin Shifting
        • Load balancing
      • Competitive games
        • Simulation Frame
        • Determinism, Prediction and Rollback
      • Team workflows
        • Version Control integration
        • Continuous Integration
      • Schema explained
        • Specification
        • Field settings
        • Archetypes
      • Code stripping
      • Replication Server CLI
      • Single-player gameplay
    • Scripting API
  • Hosting
    • Choosing where to host
    • coherence Cloud
      • Online Dashboard
      • Manage Worlds
      • Configure Rooms
      • Player Accounts
      • Game Services
        • Lobbies
        • Cloud Storage
        • Key-Value Store (Legacy)
      • APIs
        • Worlds
        • Rooms
        • Lobbies
        • Cloud Storage
        • Key-Value Store (Legacy)
    • Peer-to-peer
      • Implementing Client hosting
        • Steam Relay
        • Epic Online Services (EOS) Relay
        • Azure PlayFab Relay
  • Support
    • Release notes
    • Glossary
    • Unreal Engine support
    • WebGL support
    • ECS / DOTS support
    • Known issues
    • Upgrade guide
      • Upgrade 1.6 -> 1.7
      • Upgrade 1.5 -> 1.6
      • Upgrade 1.4 -> 1.5
      • Upgrade 1.3 -> 1.4
      • Upgrade 1.2 -> 1.3
      • Upgrade 1.1 -> 1.2
      • Upgrade 1.0 -> 1.1
      • Upgrade 0.10 -> 1.0
      • Upgrade 0.9 -> 0.10
    • Credit cost & pricing
    • Report a bug
Powered by GitBook
On this page
  • Configuring for cloud hosted Replication Server
  • Configuring for local development
  • Restricting Creating Entities
  • Disabling global query for client connections on the Coherence Bridge
  • Validating Client Connections
  • Custom user payload
  • Kicking Client Connections

Was this helpful?

Export as PDF
  1. Manual
  2. Simulators (Servers)

Advanced Simulator Authority

Last updated 1 day ago

Was this helpful?

Some games require enhanced security against cheating or player griefing. This is done by giving different authoritative privileges only to .

Configuring for cloud hosted Replication Server

In the Project Settings section of the under Advanced Authority Config, you can select which Host Authority features are enabled for rooms and worlds separately, under Rooms Host Authority and Worlds Host Authority.

Configuring for local development

In the coherence , under Local Replication Server, you can select which Host Authority features are enabled for locally run Replication Server world. Or in case you are manually launching the Replication Server from the CLI then the --host-authority-features parameter should be passed into the command where each features' value is added to the passed in value.

Eg:

replication-server worlds --host-authority-features=7

Where the values of the features are:

  • Create Entities = 1

  • Validate Connections = 2

To select which Host Authority features are enabled for locally run room, you need to set SelfHostedRoomCreationOptions.HostAuthority at room creation time.

If any host authority feature is enabled, the Replication Server will not allow clients to be connected without a simulator being connected as well.

If a client tries to connect before a simulator, the connection will be denied with the ConnectionCloseReason.HostNotReady.

If a simulator disconnects, while other clients are connected to the server, the Replication Server will forcefully disconnect all other clients as well with the ConnectionCloseReason.HostDisconnected.

Restricting Creating Entities

The HostAuthority.CreateEntities feature is used to only allow simulators to create entities. Once created, these entities can have their state authority transferred and the lifetime managed by non-simulators, but no client is allowed to create entities when this restriction is active.

Disabling global query for client connections on the Coherence Bridge

Validating Client Connections

The HostAuthority.ValidateConnection feature is used to restrict who can connect to the world or a room. Enabling this feature, on every connection attempt from a client, the connected simulator will receive a validation request, and only if the simulator responds with the accepted validation response will the connection be allowed.

To handle the connection validation requests, the simulator has to subscribe to the CoherenceBridge.onValidateConnectionRequest event and invoke the given respond delegate with the validation result:

bridge.onValidateConnectionRequest.AddListener((clientID, userPayload, respond) => {
    bool accept = Validate(clientID, userPayload); // your own validation logic
    respond(accept); // this can even be called asynchronously
});

If the simulator rejects the connection, the client will receive a connection denied error with the ConnectionCloseReason.ConnectionRejectedByHost.

Custom user payload

Before initiating the connection, the user can set an optional custom user payload which will be sent to the simulator for validation. The payload is of type byte[], and contain a token, any other content or can even be null. To send the payload for validation, you must set it before initiating the connection:

var payload = Encoding.ASCII.GetBytes(myToken);
bridge.SetConnectionValidationPayload(payload);
bridge.JoinRoom(...); // or bridge.Connect(...);

Kicking Client Connections

A simulator can forcefully disconnect other clients by kicking them. When kicking the client, the simulator can also send an optional user payload of type byte[] which will be sent to the kicked client, together with the ConnectionCloseReason.KickedByHost.

// On simulator
var payload = Encoding.ASCII.GetBytes("Kicked for griefing.");
bridge.KickConnection(clientID, payload);

// On client
bridge.onConnectionError.AddListener((bridge, exception) => 
{
    if (exception is ConnectionDeniedException deniedException &&
        deniedException.CloseReason == ConnectionCloseReason.KickedByHost) 
    {
        var message = Encoding.ASCII.GetString(deniedException.UserPayload);
        Debug.Log($"Kicked with message: {message}");
    }
});

By default, all CoherenceSyncs have set to Steal. This means that malicious players could steal the authority of any entity and break the game.

Instead of manually changing the AuthorityTransferType on every new CoherenceSync, you can change the default value of it in the coherence .

By default, when are active, the will automatically create a global query entity on behalf of the client. If the client is not authorized to create entities then this results in an error on the Replication Server indicating that an entity creation was rejected. To avoid these error logs, the auto creation of the global query can be disabled in the Coherence Bridge configuration:

A global query can be created manually as part of a prefab by using the component. This prefab can then be transferred to other clients from the simulator to give those clients access to the global client connections.

simulators
Online Dashboard
project settings
project settings
client connections
Coherence Bridge
CoherenceGlobalQuery
Uncheck the Create Global Query option
AuthorityTransferType