Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feature/thread friendly into develop #11

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions RustPlusApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrobeEntityLegacy", "RustP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToggleEntityLegacy", "RustPlusApi\Examples\Legacy\ToggleEntityLegacy\ToggleEntityLegacy.csproj", "{172AAEAA-0F46-457C-9494-8BBEE5377D66}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SetSubscriptionLegacy", "RustPlusApi\Examples\Legacy\SetSubscriptionLegacy\SetSubscriptionLegacy.csproj", "{135FF8CD-4561-4DD8-897F-A5B898DCAF17}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CheckSubscriptionLegacy", "RustPlusApi\Examples\Legacy\CheckSubscritionLegacy\CheckSubscriptionLegacy.csproj", "{846C0B38-B7F8-454C-9E3C-40DC15E0D390}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "__Events", "RustPlusApi\Examples\Legacy\__Events\__Events.csproj", "{630A388E-41EC-4AC1-9737-61759BA40164}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -231,6 +237,18 @@ Global
{172AAEAA-0F46-457C-9494-8BBEE5377D66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{172AAEAA-0F46-457C-9494-8BBEE5377D66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{172AAEAA-0F46-457C-9494-8BBEE5377D66}.Release|Any CPU.Build.0 = Release|Any CPU
{135FF8CD-4561-4DD8-897F-A5B898DCAF17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{135FF8CD-4561-4DD8-897F-A5B898DCAF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{135FF8CD-4561-4DD8-897F-A5B898DCAF17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{135FF8CD-4561-4DD8-897F-A5B898DCAF17}.Release|Any CPU.Build.0 = Release|Any CPU
{846C0B38-B7F8-454C-9E3C-40DC15E0D390}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{846C0B38-B7F8-454C-9E3C-40DC15E0D390}.Debug|Any CPU.Build.0 = Debug|Any CPU
{846C0B38-B7F8-454C-9E3C-40DC15E0D390}.Release|Any CPU.ActiveCfg = Release|Any CPU
{846C0B38-B7F8-454C-9E3C-40DC15E0D390}.Release|Any CPU.Build.0 = Release|Any CPU
{630A388E-41EC-4AC1-9737-61759BA40164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{630A388E-41EC-4AC1-9737-61759BA40164}.Debug|Any CPU.Build.0 = Debug|Any CPU
{630A388E-41EC-4AC1-9737-61759BA40164}.Release|Any CPU.ActiveCfg = Release|Any CPU
{630A388E-41EC-4AC1-9737-61759BA40164}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -272,6 +290,9 @@ Global
{F4BB95F4-2171-4087-889D-F65158AFD713} = {EBB661D0-93FF-4742-AF91-9036027CD136}
{9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161} = {EBB661D0-93FF-4742-AF91-9036027CD136}
{172AAEAA-0F46-457C-9494-8BBEE5377D66} = {EBB661D0-93FF-4742-AF91-9036027CD136}
{135FF8CD-4561-4DD8-897F-A5B898DCAF17} = {EBB661D0-93FF-4742-AF91-9036027CD136}
{846C0B38-B7F8-454C-9E3C-40DC15E0D390} = {EBB661D0-93FF-4742-AF91-9036027CD136}
{630A388E-41EC-4AC1-9737-61759BA40164} = {EBB661D0-93FF-4742-AF91-9036027CD136}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4B4251F-ADA4-418D-95B5-27BA99A307A3}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\RustPlusApi\RustPlusApi.csproj" />
<ProjectReference Include="..\..\__Constants\__Constants.csproj" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions RustPlusApi/Examples/Legacy/CheckSubscritionLegacy/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Newtonsoft.Json;

using RustPlusApi;

using static __Constants.ExamplesConst;

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);
const uint entityId = 0;

await rustPlus.ConnectAsync();

var message = await rustPlus.CheckSubscriptionLegacyAsync(entityId);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

await rustPlus.DisconnectAsync();
16 changes: 6 additions & 10 deletions RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
// This method is not fully integrated in Rust so it will not work until the Clan update is released.
var message = await rustPlus.GetClanChatLegacyAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

rustPlus.MessageReceived += (_, message) =>
rustPlus.NotificationReceived += (_, message) =>
{
if (message.Broadcast is not { ClanChanged: not null }) return;

Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

await rustPlus.ConnectAsync();
await rustPlus.ConnectAsync();

// This method is not fully integrated in Rust, so it will not work until the Clan update is released.
var message = await rustPlus.GetClanChatLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
13 changes: 5 additions & 8 deletions RustPlusApi/Examples/Legacy/GetClanChatLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
// This method is not fully integrated in Rust so it will not work until the Clan update is released.
var message = await rustPlus.GetClanChatLegacyAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
await rustPlus.ConnectAsync();

rustPlus.Dispose();
};
// This method is not fully integrated in Rust, so it will not work until the Clan update is released.
var message = await rustPlus.GetClanChatLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
14 changes: 5 additions & 9 deletions RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);
const uint entityId = 3716008;

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetEntityInfoLegacyAsync(entityId);

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

rustPlus.MessageReceived += (_, message) =>
rustPlus.NotificationReceived += (_, message) =>
{
if (message.Broadcast is not { EntityChanged: not null }) return;

Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

await rustPlus.ConnectAsync();
await rustPlus.ConnectAsync();

var message = await rustPlus.GetEntityInfoLegacyAsync(entityId);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/GetInfoLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetTeamChatLegacyAsync();
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.GetInfoLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
16 changes: 6 additions & 10 deletions RustPlusApi/Examples/Legacy/GetMapLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetMapLegacyAsync();
await rustPlus.ConnectAsync();

if (message.Response.Error is not null) return;
var message = await rustPlus.GetMapLegacyAsync();

File.WriteAllBytes("map.jpg", message.Response.Map.JpgImage.ToByteArray());
if (message.Response.Error is not null) return;

Console.WriteLine($"Image saved under: {Directory.GetCurrentDirectory()}");
File.WriteAllBytes("map.jpg", message.Response.Map.JpgImage.ToByteArray());
Console.WriteLine($"Image saved under: {Directory.GetCurrentDirectory()}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/GetMapMarkersLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetMapMarkersLegacyAsync();
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.GetMapMarkersLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
14 changes: 5 additions & 9 deletions RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetTeamChatLegacyAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

rustPlus.MessageReceived += (_, message) =>
rustPlus.NotificationReceived += (_, message) =>
{
if (message.Broadcast is not { TeamMessage: not null }) return;

Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
};

await rustPlus.ConnectAsync();
await rustPlus.ConnectAsync();

var message = await rustPlus.GetTeamChatLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/GetTeamChatLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetTeamChatLegacyAsync();
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.GetTeamChatLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/GetTeamInfoLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetTeamInfoLegacyAsync();
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.GetTeamInfoLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/GetTimeLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.GetTimeLegacyAsync();
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.GetTimeLegacyAsync();
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/PromoteToLeader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);
const ulong steamId = 0;

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.PromoteToLeaderLegacyAsync(steamId);
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.PromoteToLeaderLegacyAsync(steamId);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);
const string teamMessage = "Hello world!";

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.SendTeamMessageLegacyAsync(teamMessage);
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.SendTeamMessageLegacyAsync(teamMessage);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
12 changes: 4 additions & 8 deletions RustPlusApi/Examples/Legacy/SetEntityValueLegacy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
const uint entityId = 0;
const bool value = true;

rustPlus.Connected += async (_, _) =>
{
var message = await rustPlus.SetEntityValueLegacyAsync(entityId, value);
await rustPlus.ConnectAsync();

Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
var message = await rustPlus.SetEntityValueLegacyAsync(entityId, value);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
await rustPlus.DisconnectAsync();
15 changes: 15 additions & 0 deletions RustPlusApi/Examples/Legacy/SetSubscriptionLegacy/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Newtonsoft.Json;

using RustPlusApi;

using static __Constants.ExamplesConst;

var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken);
const uint entityId = 0;

await rustPlus.ConnectAsync();

var message = await rustPlus.SetSubscriptionLegacyAsync(entityId);
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");

await rustPlus.DisconnectAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\RustPlusApi\RustPlusApi.csproj" />
<ProjectReference Include="..\..\__Constants\__Constants.csproj" />
</ItemGroup>

</Project>
Loading
Loading