Table of Contents

Class Secrets

Namespace
DiscordRPC
Assembly
DiscordRPC.dll

The secrets used for Joining. Secrets are obfuscated data of your choosing. They could be match ids, player ids, lobby ids, etc.

To keep security on the up and up, Discord requires that you properly hash/encode/encrypt/put-a-padlock-on-and-swallow-the-key-but-wait-then-how-would-you-open-it your secrets.

You should send discord data that someone else's game client would need to join their friend. If you can't or don't want to support those actions, you don't need to send secrets.

Visit the Rich Presence How-To for more information.

[Serializable]
public class Secrets
Inheritance
Secrets
Inherited Members

Fields

MatchSecret

The unique match code to distinguish different games/lobbies. Use Secrets.CreateSecret(Random) to get an appropriately sized secret.

This cannot be null and must be supplied for the Join / Spectate feature to work.

Max Length of 128 characters

[Obsolete("This feature has been deprecated my Mason in issue #152 on the offical library. Was originally used as a Notify Me feature, it has been replaced with Join / Spectate.", true)]
[JsonIgnore]
public string MatchSecret

Field Value

string

SecretLength

The length of a secret in bytes.

public const int SecretLength = 128

Field Value

int

Properties

Encoding

The encoding the secret generator is using

public static Encoding Encoding { get; }

Property Value

Encoding

Join

The secret data that will tell the client how to connect to the game to play. This could be a unique identifier for a fancy match maker or player id, lobby id, etc.

It is recommended to encrypt this information so its hard for people to replicate it. Do NOT just use the IP address in this. That is a bad practice and can leave your players vulnerable!

Max Length of 128 characters

[JsonProperty("join", NullValueHandling = NullValueHandling.Ignore)]
public string Join { get; set; }

Property Value

string

JoinSecret

Alias of Join

[Obsolete("Property name is redundant and replaced with Join.")]
[JsonIgnore]
public string JoinSecret { get; set; }

Property Value

string

Remarks

This was made obsolete as the property name contains redundant information.

SpectateSecret

The secret data that will tell the client how to connect to the game to spectate. This could be a unique identifier for a fancy match maker or player id, lobby id, etc.

It is recommended to encrypt this information so its hard for people to replicate it. Do NOT just use the IP address in this. That is a bad practice and can leave your players vulnerable!

Max Length of 128 characters

[Obsolete("Spectating is no longer supported by Discord.")]
[JsonIgnore]
public string SpectateSecret { get; set; }

Property Value

string

Methods

CreateFriendlySecret(Random, int)

Creates a secret word using more readable friendly characters. Useful for debugging purposes. This is not a cryptographic function and should NOT be used for sensitive information.

public static string CreateFriendlySecret(Random random, int length = 128)

Parameters

random Random

The random used to generate the characters

length int

The length of the secret to generate. Defaults to SecretLength.

Returns

string

Returns a string with random alphanumeric characters

CreateSecret(Random, int)

Creates a new secret. This is NOT a cryptographic function and should NOT be used for sensitive information. This is mainly provided as a way to generate quick IDs.

public static string CreateSecret(Random random, int length = 128)

Parameters

random Random

The random to use

length int

The length of the secret to generate. Defaults to SecretLength.

Returns

string

Returns a string with random characters from Encoding