Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

image-20241014-232927.png

It is possible and useful to have multiple space connections running simultaneously within a single session. This is achieved using Tags, which are user-defined identifiers for a CavrnusSpaceConnection.

Tags

Tags allow for multiple concurrent space connections by assigning a unique identifier to each JoinSpaceWithOptions() call, using the SpaceConnectionConfig object to provide a Tag. This enables scenarios like maintaining a persistent RTC connection for communication while using another connection for tasks such as space transitions or syncing data.

When either no Tag is provided or the same Tag value is used for a JoinSpaceWithOptions() call, then only one connection remains active at a time, with new space joins replacing the current connection. By applying different tags, multiple connections can coexist, supporting advanced use cases that require simultaneous space connections.

JoinSpace() can also be used to provide a SpaceConnectionConfig, it is simply an optional parameter. If it’s not provided, the default empty string will be used as the tag.

Connecting to Multiple Spaces Example

By utilizing multiple JoinSpaceWithOptions() along with corresponding AwaitSpaceConnectionByTag() calls, multiple space connections will be created and independently handled allowing for multiple spaces to coexist simultaneously.

  public void Start()
  {
      CavrnusFunctionLibrary.AwaitAuthentication(auth => {
          var configA = new CavrnusSpaceConnectionConfig {Tag = "A"};
          CavrnusFunctionLibrary.JoinSpaceWithOptions("Space-A", configA, print, print);
          
          var configB = new CavrnusSpaceConnectionConfig {Tag = "B"};
          CavrnusFunctionLibrary.JoinSpaceWithOptions("Space-B", configB, print, print);
      });
      
      CavrnusFunctionLibrary.AwaitSpaceConnectionByTag("A", spaceConnection => {
          print("Space A is now connected!");
      });
      
      CavrnusFunctionLibrary.AwaitSpaceConnectionByTag("B", spaceConnection => {
          print("Space B is now connected!");
      });
    }
  }

Connecting to Multiple Spaces Example

  • No labels