Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7f15d2f2f | ||
|
|
e4cf09be2c | ||
|
|
1cb6f90dea | ||
|
|
94ea02ea5c |
@@ -6,7 +6,7 @@
|
||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
|
||||
|
||||
@@ -4,5 +4,9 @@ This is built using the [Discord RPC C# project](https://github.com/Lachee/disco
|
||||
|
||||
Build the DarkflameRPC.sln and run the generated DarkflameRPC.exe once you've opened your LEGO Universe game client. This doesn't start automatically with the LU client and must manually be run each time.
|
||||
|
||||
This project features images from various contributors of [the LEGO Universe Wiki](https://legouniverse.fandom.com/wiki/LEGO_Universe_Wiki) and various promotional images of the game. This application solely allows you to display current world and time elapsed playing LEGO Universe as your Discord Rich Presence.
|
||||
|
||||
# System Requirements
|
||||
|
||||
This has only been tested and confirmed to work on Windows 10, using the windows path to the client log files. This will not work on other operating systems without changes.
|
||||
|
||||
|
||||
9
docfx_project/.gitignore
vendored
@@ -1,9 +0,0 @@
|
||||
###############
|
||||
# folder #
|
||||
###############
|
||||
/**/DROP/
|
||||
/**/TEMP/
|
||||
/**/packages/
|
||||
/**/bin/
|
||||
/**/obj/
|
||||
_site
|
||||
5
docfx_project/api/.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
###############
|
||||
# temp file #
|
||||
###############
|
||||
*.yml
|
||||
.manifest
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
uid: API.Docs
|
||||
---
|
||||
|
||||
# PLACEHOLDER
|
||||
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
|
||||
@@ -1,10 +0,0 @@
|
||||
# Mono Game Setup
|
||||
|
||||
Currently no guide for Mono Game setup. Please follow the [Standard Guide](standard.md) and include the follow files from the Unity Package:
|
||||
|
||||
* The [Unity Named Pipes](https://github.com/Lachee/unity-named-pipes) Library
|
||||
* The [UnityNamedPipe.cs](https://github.com/Lachee/discord-rpc-csharp/blob/master/Unity%20Example/Assets/Discord%20RPC/Scripts/Control/UnityNamedPipe.cs)
|
||||
|
||||
# Help Wanted Here
|
||||
|
||||
Looking for those who have experience with Mono Game and implementing this library into their projects. If you have managed to successfully use this library in your project, please contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,101 +0,0 @@
|
||||
# Standard
|
||||
|
||||
The standard guide for all .NET projects.
|
||||
|
||||
## Download
|
||||
|
||||
First the library must be downloaded. For standard projects within the .NET enviorment, a nuget package is available and is updated to the latest release.
|
||||
|
||||
[](https://www.nuget.org/packages/DiscordRichPresence/)
|
||||
|
||||
```powershell
|
||||
PM> Install-Package DiscordRichPresence
|
||||
```
|
||||
|
||||
A build of the library itself can be located in the [AppVeyor Artifacts](https://ci.appveyor.com/project/Lachee/discord-rpc-csharp/build/artifacts)
|
||||
|
||||
## Usage
|
||||
|
||||
The library has 3 phases that must be followed,
|
||||
|
||||
1. Initialization
|
||||
2. Rich Presence Setting
|
||||
3. Deinitialization and Disposal
|
||||
|
||||
You can set the Rich Presence of your app at any time while the client object has been constructed. The client will store the state of the presence and automatically resend it once initialized again.
|
||||
|
||||
### Initialization
|
||||
|
||||
The creation of the client should happen once in the lifetime of the app. Where you put the constructor is upto your application design principles, but in general its always a good idea to put it in your initializers.
|
||||
|
||||
The client should be _ideally_ treated like a [singleton](https://stackoverflow.com/a/2155713/5010271) and only ever created once. Multiple instances of the client can conflict with each other and cause unpredictable results within Discord and the end users Rich Presence.
|
||||
|
||||
```cs
|
||||
public DiscordRpcClient Client { get; private set;}
|
||||
|
||||
void Setup() {
|
||||
Client = new DiscordRpcClient("my_client_id"); //Creates the client
|
||||
Client.Initialize(); //Connects the client
|
||||
}
|
||||
```
|
||||
|
||||
Note that the `Initialize()` can be called later and the current presence state will be re-sent to the Discord Client.
|
||||
|
||||
|
||||
### Setting Rich Presence
|
||||
|
||||
Setting Rich Presence is easy once the client has been initialized:
|
||||
|
||||
```cs
|
||||
//Set Presence
|
||||
client.SetPresence(new RichPresence()
|
||||
{
|
||||
Details = "Example Project",
|
||||
State = "csharp example",
|
||||
Assets = new Assets()
|
||||
{
|
||||
LargeImageKey = "image_large",
|
||||
LargeImageText = "Lachee's Discord IPC Library",
|
||||
SmallImageKey = "image_small"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
You may call this as regularly as you wish, the default behaviour of the application will ignore duplicate presence and Discord itself will handle ratelimiting.
|
||||
With that said, its always a good idea to only set the presence when there is actual change, to avoid any overheads.
|
||||
|
||||
### Disposal
|
||||
|
||||
It is important that the client is properly disposed when finished. This will safely disconnect from Discord and dispose of the resources correctly. If you have any issues with ghosting (particularly in Unity3D), make sure you dispose the client.
|
||||
|
||||
```cs
|
||||
//Dispose client
|
||||
void Cleanup() {
|
||||
client.Dispose();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Events
|
||||
|
||||
By defaults, events will be executed as they occur. This means they are executed on the **RPC Thread**, and not on the main. For most applications, this works fine and is treated as a normal event from any other library you may use. However, for applications where thread-safety is paramount (such as Game Engines), you may need to disable this feature and manually invoke events on your calling thread like so:
|
||||
|
||||
```cs
|
||||
void Start() {
|
||||
//Creates a new client, telling it not to automatically invoke the events on RPC thread.
|
||||
Client = new DiscordRpcClient("my_client_id", autoEvents: false);
|
||||
Client.Initialize();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
//Invoke the events once per-frame. The events will be executed on calling thread.
|
||||
Client.Invoke();
|
||||
}
|
||||
```
|
||||
|
||||
Please note that this method is _only_ required where cross-thread talk is a big no-no. Implementing this as a Timer would just defeat the purpose as they are [threaded anyways](https://stackoverflow.com/questions/1435876/do-c-sharp-timers-elapse-on-a-separate-thread).
|
||||
|
||||
## Further Reading
|
||||
|
||||
If you wish to implement the Join and Spectate feature within your project (those buttons), please read [Joining & Spectating Introduction](../join_spectate/intro.md) to get started.
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
# Unity3D
|
||||
|
||||
This library has full Unity3D intergration and custom editor scripts to help enhance your usage with the library. Please note there are some technical limitations with Unity3D however:
|
||||
|
||||
* .NET 2.0+ is required (no subset).
|
||||
* Newtonsoft.Json is required.
|
||||
* Native Named Pipe Wrapper is required.
|
||||
|
||||
Luckily the provided Unity Package handles all this for you.
|
||||
|
||||
## Download
|
||||
|
||||
Use the automatically built `.UnityPackage` that can be found in the artifacts of the AppVoyer build. This contains the extra dependencies for the platform and full editor support to make it easier to use.
|
||||
|
||||
[Download Package](https://ci.appveyor.com/project/Lachee/discord-rpc-csharp/build/artifacts) and import into your project.
|
||||
|
||||
[](https://ci.appveyor.com/project/Lachee/discord-rpc-csharp/build/artifacts)
|
||||
|
||||
## Importing
|
||||
|
||||
Import the unity package normally and make sure all content is selected. Once imported you may get the following warning. This library does not support the .NET 2.0 **Subset** and requires the full .NET 2.0 or greater. Proceeding with `Yes` will convert the project automatically to .NET 2.0.
|
||||
|
||||

|
||||
|
||||
## Creating a Manager
|
||||
|
||||
The Discord Manager is a wrapper class around the DiscordRpcClient. It will handle the initialization, deinitialization and event invoking for you automatically.
|
||||
|
||||
Create a new Discord Manager in your very first loaded scene by following `GameObject -> Discord Manager`.
|
||||
|
||||

|
||||
|
||||
### Discord Manager Inspector
|
||||
|
||||
Once created, a new object will appear in your scene. You can _only_ have 1 Discord Manager at a time and any extras will automatically be deleted. The manager has some default values, but will need to be configured to your application.
|
||||
|
||||
| Property | Description |
|
||||
|----------|-------------|
|
||||
| Application ID | The Client ID of your Discord App created in the [Developer Portal](https://discordapp.com/developers/applications/). |
|
||||
| Steam ID | A optional Steam App ID of your game. This will let Discord launch your game through the steam client instead of directly when using the [Join & Spectate](/join_spectate/intro.md) |
|
||||
| Target Pipe | The pipe your Discord Client is running on. If you have 2 clients running for testing purposes, you can switch which client the game connects too. |
|
||||
| Log Level | The level of logging to receive from the DiscordRpcClient. |
|
||||
| Register Uri Scheme | Registers a custom URI scheme so Discord can launch your game. Only required if using the [Join & Spectate](/join_spectate/intro.md) feature. |
|
||||
| Active | If enabled, the Discord Manager will create a connection and maintain it. |
|
||||
| **State** | The current state of the connected client. These values are generally `Read Only` |
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Setting Rich Presence is done via your game code. It is upto you on how you implement it, but as an example from the Survival Shooter example by Unity3D:
|
||||
|
||||
```cs
|
||||
public void UpdatePresence()
|
||||
{
|
||||
presence.state = "Score: " + CompleteProject.ScoreManager.score;
|
||||
presence.largeAsset = new DiscordAsset()
|
||||
{
|
||||
image = health.isDead ? "dead" : "alive",
|
||||
tooltip = health.currentHealth + "HP"
|
||||
};
|
||||
|
||||
DiscordManager.current.SetPresence(presence);
|
||||
}
|
||||
```
|
||||
|
||||
## Further Reading
|
||||
|
||||
If you wish to implement the Join and Spectate feature within your project (those buttons), please read [Joining & Spectating Introduction](../join_spectate/intro.md) to get started.
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
uid: Articles.Intro
|
||||
---
|
||||
|
||||
# Getting started with DiscordRPC C#
|
||||
|
||||
Getting started with DiscordRPC-C# is easy! With automatic nuget packages and a fully fledge Unity3D package, you can get started in no time.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [Newtonsoft.JSON](https://www.newtonsoft.com/json)
|
||||
* .NET 3.5+ _or_ Unity3D 5.5+
|
||||
|
||||
## Select Project Type
|
||||
|
||||
[**Standard .NET Project**](getting_started/standard.md) - Recommended. For most users that are making a .NET Application
|
||||
|
||||
[**Unity3D Project**](getting_started/unity3d.md) - For Unity3D users that want to add Rich Presence to their game.
|
||||
|
||||
[**MonoGame Project / Modding**](getting_started/monogame.md) - For developers using custom MonoGame engines or modding existing games.
|
||||
|
||||
## Need More Help?
|
||||
|
||||
[](https://github.com/Lachee/discord-rpc-csharp/issues)
|
||||
|
||||
Still stuck? Make a [new GitHub issue](https://github.com/Lachee/discord-rpc-csharp/issues/new)!
|
||||
@@ -1,5 +0,0 @@
|
||||
# Join / Spectate
|
||||
Discord Rich Presence can serve as a form of match maker for your game. You can display a "Join" and "Spectate" button on your Rich Presence to allow people to connect directly through discord.
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,5 +0,0 @@
|
||||
# ToDo
|
||||
Documentation is current not written for this subject
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,5 +0,0 @@
|
||||
# ToDo
|
||||
Documentation is current not written for this subject
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,5 +0,0 @@
|
||||
# ToDo
|
||||
Documentation is current not written for this subject
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,5 +0,0 @@
|
||||
# ToDo
|
||||
Documentation is current not written for this subject
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,5 +0,0 @@
|
||||
# Rich Presence
|
||||
Rich Presence needs to be initially setup on your Discord Developer Portal and it's recommended to follow the [Best Practices](https://discordapp.com/developers/docs/rich-presence/best-practices).
|
||||
|
||||
# Help Wanted Here
|
||||
Contribute with what you know and how you did it with a new PR on the [GitHub Repository](https://github.com/Lachee/discord-rpc-csharp)
|
||||
@@ -1,20 +0,0 @@
|
||||
- name: Introduction
|
||||
href: intro.md
|
||||
- name: Getting started
|
||||
items:
|
||||
- name: Standard Project
|
||||
href: getting_started/standard.md
|
||||
- name: Unity3D Project
|
||||
href: getting_started/unity3d.md
|
||||
- name: Mono Game Project
|
||||
href: getting_started/monogame.md
|
||||
- name: Join / Spectate
|
||||
items:
|
||||
- name: Introduction
|
||||
href: join_spectate/intro.md
|
||||
- name: Getting Requests
|
||||
href: join_spectate/join_requests.md
|
||||
- name: Joining Games
|
||||
href: join_spectate/join.md
|
||||
- name: Specating Games
|
||||
href: join_spectate/spectate.md
|
||||
@@ -1 +0,0 @@
|
||||
docfx docfx.json --serve
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"metadata": [
|
||||
{
|
||||
"src": [
|
||||
{
|
||||
"src": "../",
|
||||
"files": [
|
||||
"**.csproj"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dest": "api"
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
"sitemap":{
|
||||
"baseUrl": "https://lachee.github.io/discord-rpc-csharp/docs"
|
||||
},
|
||||
"content": [
|
||||
{
|
||||
"files": [
|
||||
"api/**.yml",
|
||||
"api/index.md"
|
||||
]
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"articles/**.md",
|
||||
"articles/**/toc.yml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"toc.yml",
|
||||
"index.md"
|
||||
]
|
||||
}
|
||||
],
|
||||
"resource": [
|
||||
{
|
||||
"files": [
|
||||
"images/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dest": "../docs",
|
||||
"globalMetadata": {
|
||||
"_appFooter": "© 2019 Lachee"
|
||||
},
|
||||
"template": [
|
||||
"default"
|
||||
],
|
||||
"xrefService": [
|
||||
"https://xref.docs.microsoft.com/query?uid={uid}"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 787 KiB |
|
Before Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,42 +0,0 @@
|
||||
# Discord Rich Presence
|
||||
|
||||
[](https://ci.appveyor.com/project/Lachee/discord-rpc-csharp) [](https://www.nuget.org/packages/DiscordRichPresence/)
|
||||
[](https://github.com/Lachee/discord-rpc-csharp) [](https://ko-fi.com/P5P2YOWG)
|
||||
|
||||
This is a C# _implementation_ of the [Discord RPC](https://github.com/discordapp/discord-rpc) library which was originally written in C++. This avoids having to use the official C++ and instead provides a managed way of using the Rich Presence within the .NET environment*.
|
||||
|
||||
This library supports all features of the Rich Presence that the official C++ library supports, plus a few extra:
|
||||
|
||||
- **Message Queuing**
|
||||
- **Threaded Reads**
|
||||
- **Managed Pipes**
|
||||
- **Error Handling** & **Error Checking** with automatic reconnects
|
||||
- **Events from Discord** (such as presence update and join requests)
|
||||
- **Full Rich Presence Implementation** (including Join / Spectate)
|
||||
- **Inline Documented** (for all your intelli-sense needs)
|
||||
- **Helper Functionality** (eg: AvatarURL generator from Join Requests)
|
||||
- **Ghost Prevention** (Tells discord to clear the RP on disposal)
|
||||
- **Full Unity3D Editor** (Contains all the tools, inspectors and helpers for a Unity3D game all in one package).
|
||||
|
||||
## Quick Start
|
||||
|
||||
Check out the [Introduction](/articles/intro.html) article on how to get your Rich Presence working. Here is a summary of what is given:
|
||||
|
||||
1. Download on [Nuget](https://nuget.org/packages/DiscordRichPresence/) or [Artifacts](https://ci.appveyor.com/project/Lachee/discord-rpc-csharp/build/artifacts)
|
||||
2. Include [Newtonsoft.JSON](https://www.newtonsoft.com/json) Dependency
|
||||
3. Setup the client:
|
||||
|
||||
```cs
|
||||
client = new DiscordRpcClient("myappid");
|
||||
client.Initialize();
|
||||
```
|
||||
|
||||
4. Send Presence: `client.SetPresence(presence);`
|
||||
5. Invoke Events Regularly: `client.Invoke();`
|
||||
6. Dispose when done: `client.Dispose();`
|
||||
|
||||
## Need More Help?
|
||||
|
||||
[](https://github.com/Lachee/discord-rpc-csharp/issues)
|
||||
|
||||
Need more help or looking for some of the more advance features? Check out the [articles](/articles/intro.html) for more details on advance topics. Still stuck? Make a [new GitHub issue](https://github.com/Lachee/discord-rpc-csharp/issues/new)!
|
||||
@@ -1,6 +0,0 @@
|
||||
- name: Articles
|
||||
href: articles/
|
||||
topicUid: Articles.Intro
|
||||
- name: API Documentation
|
||||
href: api/
|
||||
topicUid: API.Docs
|
||||