Exemplo n.º 1
0
        /// <summary>
        /// Creates a new Discord RPC Client using the steam uri scheme.
        /// </summary>
        /// <param name="applicationID">The ID of the application created at discord's developers portal.</param>
        /// <param name="steamID">The steam ID of the app. This is used to launch Join / Spectate through steam URI scheme instead of manual launching</param>
        /// <param name="registerUriScheme">Should a URI scheme be registered for Join / Spectate functionality? If false, the Join / Spectate functionality will be disabled.</param>
        /// <param name="pipe">The pipe to connect too. -1 for first available pipe.</param>
        /// <param name="client">The pipe client to use and communicate to discord through</param>
        /// <param name="logger">The logger used to report messages. Its recommended to assign here so it can report the results of RegisterUriScheme.</param>
        public DiscordRpcClient(string applicationID, string steamID, bool registerUriScheme, int pipe, INamedPipeClient client, ILogger logger = null)
        {
            //Store our values
            ApplicationID          = applicationID;
            SteamID                = steamID;
            HasRegisteredUriScheme = registerUriScheme;
            ProcessID              = System.Diagnostics.Process.GetCurrentProcess().Id;
            _pipe   = pipe;
            _logger = logger == null ? new NullLogger() : logger;

            //If we are to register the URI scheme, do so.
            //The UriScheme.RegisterUriScheme function takes steamID as a optional parameter, its null by default.
            //   this means it will handle a null steamID for us :)
            if (registerUriScheme)
            {
                UriScheme.RegisterUriScheme(_logger, applicationID, steamID);
            }

            //Create the RPC client
            connection = new RpcConnection(ApplicationID, ProcessID, TargetPipe, client)
            {
                ShutdownOnly = _shutdownOnly
            };
            connection.Logger = this._logger;
        }
Exemplo n.º 2
0
 public DiscordRpcClient(
     string applicationID,
     string steamID,
     bool registerUriScheme,
     int pipe,
     INamedPipeClient client)
 {
     this.ApplicationID          = applicationID;
     this.SteamID                = steamID;
     this.HasRegisteredUriScheme = registerUriScheme;
     this.ProcessID              = Process.GetCurrentProcess().Id;
     this._pipe = pipe;
     if (registerUriScheme)
     {
         UriScheme.RegisterUriScheme(applicationID, steamID, (string)null);
     }
     this.connection = new RpcConnection(this.ApplicationID, this.ProcessID, this.TargetPipe, client)
     {
         ShutdownOnly = this._shutdownOnly
     };
     this.connection.Logger = this._logger;
 }