CLI

Command-line interface tools explained

Found in <package-root>/.Runtime/<platform>/.

protocol-code-generator

General help flags

protocol-code-generator --help

Code Generation

protocol-code-generator --help generate

  -d, --schema=STRING                 The schema file (.schema).
  -o, --output=STRING                 Output file.
      --output-dir=STRING             Output directory (can only be used together with --split).
  -c, --code=STRING                   Which language to generate code for.
  -e, --ecs=STRING                    Which flavour of ECS to generate code for.
      --split                         Split into files.
      --debugoutput                   Insert debug output in generated code.
      --sync=STRING                   Path to Unity generated JSON file for creating the generated.schema file.
      --emit-empty                    Emit empty baked scripts. Useful to avoid possible compile errors.
      --namespace-suffix=STRING       Namespace suffix to use for generated code.

Replication Server

replication-server --help serve

      --port=32001                                  The port to listen to.
      --stats-port=32000                            The port to listen for stats scrapers. Also enables pprof.
      --use-p-prof                                  If StatsPort is 0 then setup pprof on port 6060.
      --dump                                        Write network packets to capture files (.packets).
      --dump-reverse                                Write network packets reversing in and out packets
      --frequency=20                                [Obsolete] use SendFrequency instead.
      --send-frequency=20                           The server send frequency.
      --recv-frequency=60                           The server packet receive frequency packets/s. Packets received faster than this will be dropped and the connection throttled.
      --schema=STRING                               The schema file (.schema).
      --disconnect-timeout=5000                     Disconnect timeout (in milliseconds).
      --debug-streams                               Use debug streams.
      --max-entities=65536                          Maximum number of entities allowed.
      --max-clients=200                             Expected maximum number of clients.
      --min-query-distance=0.1                      Minimum distance for query change.
      --web-support                                 [Deprecated] Does this support web connections.
      --public-ip=STRING                            Public IP of the replication server, used by webrtc.
      --web-port=32003                              Port for webrtc, only used if --web-support is true
      --signalling-port=32002                       Port for signalling, only used if --web-support is true
      --out-stats-freq=1                            Frequency, in seconds, of updates to prometheus stats
      --log-stats-freq=0                            Frequency, in seconds, of output of stats to INFO logs. 0 - no output
      --env="prod"                                  Environment in which the server is executed
      --secret="local-development"                  Secret used for API request and client authentication. The default value is used during local development only.
      --project-id="local"                          ID of the project as assigned by the portal.
      --persistence-enabled                         If enabled, starts replication server with persistence attached.
      --persistence-save-file-name="world.save"     The name of the persistent save file.
      --persistence-save-folder="."                 The folder where the save file is written.
      --persistence-save-frequency=30               The frequency in which the save file is written (in seconds).
      --persistence-query-world-position="0,0,0"    Position of the center of the entity query.
      --persistence-query-radius=10000              Radius of entity query.
      --persistence-disable-s-3-storage             Enable to disable storing to S3.
      --persistence-upload-size-threshold=1024      Difference in bytes to cause an s3 upload.
      --persistence-upload-frequency-forced=3600    The maximum number of seconds between forced s3 uploads.

To start the Server, you need to give it the location of the schema.

You can copy the CLI commands to start the replication server form coherence Hub > Servers tab_._

You can also define other parameters like min-query-distance (the minimum distance the LiveQuery needs to move for the Replicator to recognize a change), send and receive frequency, ip and port number.

Minimal parameters set is presented in the example below:

replication-server serve --port 32001 --signalling-port 32002 --send-frequency 20 --recv-frequency 60 --web-support --env dev --schema "/Users/coherence/unity/Coherence.Toolkit/Toolkit.schema,/Users/coherence/MyProject/Library/coherence/Gathered.schema"

replication-server --help listen

      --port=64001                    The port to listen to.
      --default-frequency=20          [Obsolete] use SendFrequency instead.
      --send-frequency=20             The frequency to send data to the clients. Packets/s.
      --recv-frequency=60             The server packet receive frequency packets/s. Packets received faster than this will be dropped and the connection throttled.
      --default-schema=STRING         The default schema file (.schema).
      --stats-port=64000              The port to listen for stats scrapers. Also enables pprof
      --use-p-prof                    If StatsPort is 0 then setup pprof on port 6060.
      --udp-port=42001                Port for udp traffic.
      --web-support                   [Deprecated] Does this support web connections.
      --web-port=42003                Port for webrtc, only used if --web-support is true
      --public-ip=STRING              Public IP of the replication server, used by webrtc.
      --signalling-port=42002         Port for signalling, only used if --web-support is true
      --disconnect-timeout=5000       Disconnect timeout (in milliseconds).
      --out-stats-freq=1              Frequency, in seconds, of updates to prometheus stats
      --log-stats-freq=0              Frequency, in seconds, of output of stats to INFO logs. 0 - no output
      --env="prod"                    Environment in which the server is executed
      --region=STRING                 Region in which the server is located
      --secret="local-development"    Secret used for API request and client authentication. The default value is used during local development only.
      --room-size-limit=100           The hard limit of max clients in a room enforced at room creation
      --has-persistence               Does this support enabling persistence.
      --grpc-address=STRING           Address for realtime streaming of room/world updates
      --rsid=STRING                   Replication server unique ID

Persistence Client

persistence-client --help serve

      --save-file-name="world.save"     The name of the persistent save file.
      --save-folder="."                 The folder where the save file is written.
      --save-frequency=30               The frequency in which the save file is written (in seconds).
      --host="127.0.0.1:32001"          The host:port to connect to.
      --room-id=0                       The room id to connect to.
      --room-uid=0                      The unique room id to connect to.
      --auth-token=STRING               Token used for authenticating client upon connection
      --stats-port=32000                The port to listen for stats scrapers.
      --dump                            Write network packets to capture files (.packets).
      --send-frequency=20               The server send frequency. Packets/s.
      --recv-frequency=20               The client packet receive frequency. Packets/s.
      --schema=STRING                   The schema file (.schema).
      --max-entities=32767              The maximum number of entities saved
      --disconnect-timeout=5000         Disconnect timeout (in milliseconds).
      --debug-streams                   Use debug streams.
      --query-world-position="0,0,0"    Position of the center of the entity query.
      --query-radius=10000              Radius of entity query.
      --disable-s-3-storage             Enable to disable storing to S3.
      --upload-size-threshold=1024      Difference in bytes to cause an s3 upload.
      --upload-frequency-forced=3600    The maximum number of seconds between forced s3 uploads.