How to Use Various IDs

Strix uses various IDs. Some of them are for use in Strix applications, and some others are primarily used by Strix internally. This how-to explains major ones and shows some example usages.

IDs explained

The following list summarizes major IDs available in Strix Unity SDK.

  • Application ID (type: string)

    • An application ID identifies an application (a game title). Usually, a Strix game client takes care of exactly one application ID.

    • Strix servers and clients use application ID to ensure that they are talking to appropriate peers.

      Note

      Application ID is like a password. Don’t expose your application ID to the public.

    • When using Strix Cloud, an application ID is automatically generated and presented on the Application Dashboard.

    • In Strix Unity SDK, application ID is available as applicationId property of the StrixNetwork singleton.

  • UID (type: UID)

    • UID stands for unique identifier. It identifies various objects, and they are unique over network (within a cluster’s domain).

      Note

      UID does not stand for user id. Although each user (player) has their own UID associated with them, a UID may identify an object that is unrelated to a user.

    • The UID is not a simple value. In Strix Unity SDK, UID type is defined as an interface (though the name doesn’t begin with “I”), and there are several concrete classes implementing it. It is generally not advisable to downcast an UID object to a concrete class (or try to do something that requires such a downcast) in a client application.

    • All UID implementation classes (naturally) implement Equals(object) method with compatible GetHashCode() method. Also, ToString() methods of UID implementation are guaranteed to return a unique string that identifies the UID among all UID implementation classes.

      Your script can check for equality of given UID objects, but it is discouraged to do anything beyond it.

      Note

      UID type is an interface, so the equality operator (==) is not overloaded for it. You should not use == or != when comparing two UID objects.

    • UID is available for various objects in various contexts in Strix Unity SDK.

  • Object Type (type: int)

    • An object type identifies a type of a game object that a StrixReplicator is attached to.

    • An object type value is assigned to each of such game objects in Unity Editor during development. StrixReplicator uses the object type to distinguish an object when creating a replica.

    • If an object that a StrixReplicator is attached to is a prefab, all objects instantiated from the prefab share the same object type.

    • Object type is primarily for internal use by Strix. It is available as objectType property of StrixReplicator component.

    • Object type is also called Type ID.

  • Network Instance ID (type: long)

    • A network instance ID identifies a game object instance that a StrixReplicator component is attached to, equating replicas with their original.

    • All replicas of a same object, as well as the original object, share the same network instance ID. On the other hand, if you instantiate a same prefab twice, the two replicas created on a client will have separate network instance IDs, because they are replicas of two separate objects.

    • Network instance ID is primarily for internal use by Strix. It is available as networkInstanceId property of StrixReplicator component.

    • Network instance ID is also called Network object ID or just Network ID.

    A single prefab instantiated twice and replicated
  • Primary Key (type: long)

    • Primary key is an identifier with that a server identifies an object among those of same kind. Primary keys for objects of different kinds are unrelated. It is like a primary key of a database table in that the role of a primary key is common but what it identifies vary for different tables.

    • Many Strix objects have their primary keys in them, and the primary keys, if any, are usually available by methods of name GetPrimaryKey.

    • Some objects may even have SetPrimaryKey method that sets a primary key, but they are strictly for Strix’s internal use, and your scripts should never use them.

    • If you are to use a primary key, please be reminded that primary keys for unrelated objects of different kinds may coincidentally have a same value. You can compare two primary keys only if they are of same kind.

      Note

      This point contrasts with UID: Two UIDs for different kinds of objects never equal to each other.

  • Room ID (type: long)

    • A room ID identifies a room within a single room server. It is actually a primary key of the room object on the room server.

    • Room IDs of rooms on different room servers are unrelated, and they may coincidentally have a same value.

Identifying a joined member in RoomJoinNotified

When a new member joins a room, a RoomJoinNotified event fires, and its event handlers are invoked.

The handler has the following signature:

void RoomJoinNotificationEventHandler(
  NotificationEventArgs<RoomJoinNotification<CustomizableMatchRoom>> notification)

You can get various IDs from the notification argument:

  • notification.Data.GetPrimaryKey() returns a primary key of the room where a new member joined, which is the room the current client is in.

  • notification.Data.GetNewlyJoinedMember().GetPrimaryKey() returns a primary key of the room member who has joined.

  • notification.Data.GetNewlyJoinedMember().GetUid() returns a UID of the room member who has joined.