You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DiscordRPC/DiscordRpcClient.cs
+33-8Lines changed: 33 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ namespace DiscordRPC
12
12
{
13
13
14
14
/// <summary>
15
-
/// A Discord RPC Client which is used to send Rich Presence updates and receive Join / Spectate events.
15
+
/// A Discord RPC Client which is used to send Rich Presence updates and receive Join events.
16
16
/// </summary>
17
17
publicsealedclassDiscordRpcClient:IDisposable
18
18
{
19
19
#region Properties
20
20
21
21
22
22
/// <summary>
23
-
/// Gets a value indicating if the client has registered a URI Scheme. If this is false, Join / Spectate events will fail.
23
+
/// Gets a value indicating if the client has registered a URI Scheme. If this is false, Join events will fail.
24
24
/// <para>To register a URI Scheme, call <see cref="RegisterUriScheme(string, string)"/>.</para>
25
25
/// </summary>
26
26
publicboolHasRegisteredUriScheme{get;privateset;}
@@ -172,6 +172,7 @@ public bool ShutdownOnly
172
172
/// Called when the Discord Client wishes for this process to spectate a game.
173
173
/// <para>If <see cref="AutoEvents"/> is true then this event will execute on a different thread. If it is not true however, then this event is not invoked untill <see cref="Invoke"/> and will be on the calling thread.</para>
174
174
/// </summary>
175
+
[System.Obsolete("Spectating is no longer supported by Discord.")]
175
176
publiceventOnSpectateEventOnSpectate;
176
177
177
178
/// <summary>
@@ -201,13 +202,13 @@ public bool ShutdownOnly
201
202
#region Initialization
202
203
203
204
/// <summary>
204
-
/// Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join / Spectate events.
205
+
/// Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join events.
205
206
/// </summary>
206
207
/// <param name="applicationID">The ID of the application created at discord's developers portal.</param>
/// Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join / Spectate events. This constructor exposes more advance features such as custom NamedPipeClients and Loggers.
211
+
/// Creates a new Discord RPC Client which can be used to send Rich Presence and receive Join events. This constructor exposes more advance features such as custom NamedPipeClients and Loggers.
211
212
/// </summary>
212
213
/// <param name="applicationID">The ID of the application created at discord's developers portal.</param>
213
214
/// <param name="pipe">The pipe to connect too. If -1, then the client will scan for the first available instance of Discord.</param>
/// Respond to a Join Request. All requests will timeout after 30 seconds.
428
+
/// <para>Because of the 30 second timeout, it is recommended to call <seealso cref="Invoke"/> faster than every 15 seconds to give your users adequate time to respond to the request.</para>
429
+
/// </summary>
430
+
/// <param name="user">The user to respond to.</param>
431
+
/// <param name="acceptRequest">Accept the join request.</param>
432
+
publicvoidRespond(Useruser,boolacceptRequest)
433
+
=>Respond(user.ID,acceptRequest);
434
+
435
+
/// <summary>
436
+
/// Respond to a Join Request. All requests will timeout after 30 seconds.
437
+
/// <para>Because of the 30 second timeout, it is recommended to call <seealso cref="Invoke"/> faster than every 15 seconds to give your users adequate time to respond to the request.</para>
438
+
/// </summary>
439
+
/// <param name="userID">The ID of the user to respond to.</param>
440
+
/// <param name="acceptRequest">Accept the join request.</param>
/// Registers the application executable to a custom URI Scheme.
695
-
/// <para>This is required for the Join and Spectate features. Discord will run this custom URI Scheme to launch your application when a user presses either of the buttons.</para>
718
+
/// <para>This is required for the Join feature. Discord will run this custom URI Scheme to launch your application when a user presses either of the buttons.</para>
696
719
/// </summary>
697
720
/// <param name="steamAppID">Optional Steam ID. If supplied, Discord will launch the game through steam instead of directly calling it.</param>
698
721
/// <param name="executable">The path to the executable. If null, the path to the current executable will be used instead.</param>
thrownewInvalidConfigurationException("Cannot subscribe/unsubscribe to an event as this application has not registered a URI Scheme. Call RegisterUriScheme().");
774
797
775
798
//Add the subscribe command to be sent when the connection is able too
799
+
#pragma warning disable CS0618// Type or member is obsolete
/// URL that is linked to when clicking on the details text in the activity card.
73
73
/// <para>Max 256 characters</para>
@@ -107,7 +107,7 @@ public string DetailsUrl
107
107
publicPartyParty{get;set;}
108
108
109
109
/// <summary>
110
-
/// The secrets used for Join / Spectate. Secrets are obfuscated data of your choosing. They could be match ids, player ids, lobby ids, etc. Make this object null if you do not wish too / unable too implement the Join / Request feature.
110
+
/// The secrets used for Joining. Secrets are obfuscated data of your choosing. They could be match ids, player ids, lobby ids, etc. Make this object null if you do not wish too / unable too implement the Join / Request feature.
111
111
/// <para>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.</para>
112
112
/// <para>Visit the <see href="https://discordapp.com/developers/docs/rich-presence/how-to#secrets">Rich Presence How-To</see> for more information.</para>
Copy file name to clipboardExpand all lines: DiscordRPC/Entities/Secrets.cs
+23-31Lines changed: 23 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@
6
6
namespaceDiscordRPC
7
7
{
8
8
/// <summary>
9
-
/// The secrets used for Join / Spectate. Secrets are obfuscated data of your choosing. They could be match ids, player ids, lobby ids, etc.
9
+
/// The secrets used for Joining. Secrets are obfuscated data of your choosing. They could be match ids, player ids, lobby ids, etc.
10
10
/// <para>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.</para>
11
-
/// <para>You should send discord data that someone else's game client would need to join or spectate their friend. If you can't or don't want to support those actions, you don't need to send secrets.</para>
11
+
/// <para>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.</para>
12
12
/// <para>Visit the <see href="https://discordapp.com/developers/docs/rich-presence/how-to#secrets">Rich Presence How-To</see> for more information.</para>
13
13
/// </summary>
14
14
[Serializable]
@@ -20,6 +20,7 @@ public class Secrets
20
20
/// <para>Max Length of 128 characters</para>
21
21
/// </summary>
22
22
[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)]
23
+
[JsonIgnore]
23
24
publicstringMatchSecret;
24
25
25
26
/// <summary>
@@ -44,6 +45,7 @@ public string Join
44
45
/// <summary>Alias of Join</summary>
45
46
/// <remarks>This was made obsolete as the property name contains redundant information.</remarks>
46
47
[System.Obsolete("Property name is redundant and replaced with Join.")]
/// <remarks>This was made obsolete as the property name contains redundant information.</remarks>
75
-
[System.Obsolete("Property name is redundant and replaced with Spectate.")]
76
-
publicstringSpectateSecret
77
-
{
78
-
get=>Spectate;
79
-
set=>Spectate=value;
80
-
}
81
-
62
+
[System.Obsolete("Spectating is no longer supported by Discord.")]
63
+
[JsonIgnore]
64
+
publicstringSpectateSecret{get;set;}
82
65
#region Statics
83
66
84
67
/// <summary>
@@ -89,18 +72,22 @@ public string SpectateSecret
89
72
/// <summary>
90
73
/// The length of a secret in bytes.
91
74
/// </summary>
92
-
publicstaticintSecretLength=>128;
75
+
publicconstintSecretLength=128;
93
76
94
77
/// <summary>
95
78
/// 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.
96
79
/// </summary>
97
80
/// <param name="random">The random to use</param>
98
-
/// <returns>Returns a <see cref="SecretLength"/> sized string with random characters from <see cref="Encoding"/></returns>
99
-
publicstaticstringCreateSecret(Randomrandom)
81
+
/// <param name="length">The length of the secret to generate. Defaults to <see cref="SecretLength"/>.</param>
82
+
/// <returns>Returns a string with random characters from <see cref="Encoding"/></returns>
thrownewArgumentOutOfRangeException(nameof(length),"Secret length must be between 1 and 128 characters.");
87
+
101
88
//Prepare an array and fill it with random bytes
102
89
// THIS IS NOT SECURE! DO NOT USE THIS FOR PASSWORDS!
103
-
byte[]bytes=newbyte[SecretLength];
90
+
byte[]bytes=newbyte[length];
104
91
random.NextBytes(bytes);
105
92
106
93
//Return the encoding. Probably should remove invalid characters but cannot be fucked.
@@ -112,13 +99,18 @@ public static string CreateSecret(Random random)
112
99
/// 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.
113
100
/// </summary>
114
101
/// <param name="random">The random used to generate the characters</param>
0 commit comments