Skip to content

Commit

Permalink
add samples
Browse files Browse the repository at this point in the history
  • Loading branch information
HandyS11 committed Mar 20, 2024
1 parent c5ecce6 commit 8addc32
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 6 deletions.
37 changes: 36 additions & 1 deletion RustPlusApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RustPlusApi", "RustPlusApi\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exemples", "Exemples", "{BC948ADE-1674-4955-B27C-F0E96100978E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendTeamChat", "RustPlusApi\Exemples\SendTeamChat\SendTeamChat.csproj", "{FC788BAA-BB25-48AD-BE3D-2046C111AD00}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SendTeamChat", "RustPlusApi\Exemples\SendTeamChat\SendTeamChat.csproj", "{FC788BAA-BB25-48AD-BE3D-2046C111AD00}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTime", "RustPlusApi\Exemples\GetTime\GetTime.csproj", "{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetMap", "RustPlusApi\Exemples\GetMap\GetMap.csproj", "{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTeamInfo", "RustPlusApi\Exemples\GetTeamInfo\GetTeamInfo.csproj", "{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "__Constants", "RustPlusApi\Exemples\__Constants\__Constants.csproj", "{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetInfo", "RustPlusApi\Exemples\GetInfo\GetInfo.csproj", "{50B6AABF-6BC2-4B7B-BB48-27200B05476F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -23,12 +33,37 @@ Global
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Release|Any CPU.Build.0 = Release|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Release|Any CPU.Build.0 = Release|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Release|Any CPU.Build.0 = Release|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Release|Any CPU.Build.0 = Release|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Release|Any CPU.Build.0 = Release|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FC788BAA-BB25-48AD-BE3D-2046C111AD00} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{50B6AABF-6BC2-4B7B-BB48-27200B05476F} = {BC948ADE-1674-4955-B27C-F0E96100978E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4B4251F-ADA4-418D-95B5-27BA99A307A3}
Expand Down
15 changes: 15 additions & 0 deletions RustPlusApi/Exemples/GetInfo/GetInfo.csproj
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>
17 changes: 17 additions & 0 deletions RustPlusApi/Exemples/GetInfo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using __Constants;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);

rustPlus.Connected += async (sender, e) =>
{
await rustPlus.GetInfoAsync(message =>
{
Console.WriteLine($"Infos: " +
$"\nServer Name: {message.Response.Info.Name}" +
$"\nServer Url: {message.Response.Info.Url}");
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
15 changes: 15 additions & 0 deletions RustPlusApi/Exemples/GetMap/GetMap.csproj
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>
16 changes: 16 additions & 0 deletions RustPlusApi/Exemples/GetMap/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using __Constants;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);

rustPlus.Connected += async (sender, e) =>
{
await rustPlus.GetMapAsync(message =>
{
var imageData = message.Response.Map.JpgImage.ToByteArray();
File.WriteAllBytes("map.jpg", imageData);
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
15 changes: 15 additions & 0 deletions RustPlusApi/Exemples/GetTeamInfo/GetTeamInfo.csproj
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>
17 changes: 17 additions & 0 deletions RustPlusApi/Exemples/GetTeamInfo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using __Constants;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);

rustPlus.Connected += async (sender, e) =>
{
await rustPlus.GetTeamInfoAsync(message =>
{
Console.WriteLine($"Infos:" +
$"\nLeader SteamId: {message.Response.TeamInfo.LeaderSteamId}" +
$"\nMembers Count: {message.Response.TeamInfo.Members.Count}");
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
15 changes: 15 additions & 0 deletions RustPlusApi/Exemples/GetTime/GetTime.csproj
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/Exemples/GetTime/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using __Constants;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);

rustPlus.Connected += async (sender, e) =>
{
await rustPlus.GetTimeAsync(message =>
{
Console.WriteLine($"Time: {message.Response.Time.Time}");
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
7 changes: 2 additions & 5 deletions RustPlusApi/Exemples/SendTeamChat/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const string ip = "";
const int port = 0;
const ulong playerId = 0;
const int playerToken = 0;
using __Constants;

var rustPlus = new RustPlusApi.RustPlusApi(ip, port, playerId, playerToken);
var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);

rustPlus.Connected += async (sender, e) =>
{
Expand Down
1 change: 1 addition & 0 deletions RustPlusApi/Exemples/SendTeamChat/SendTeamChat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

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

</Project>
10 changes: 10 additions & 0 deletions RustPlusApi/Exemples/__Constants/RustPlusConst.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace __Constants
{
public record RustPlusConst
{
public const string Ip = "";
public const int Port = 0;
public const ulong PlayerId = 0;
public const int PlayerToken = 0;
}
}
9 changes: 9 additions & 0 deletions RustPlusApi/Exemples/__Constants/__Constants.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

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

</Project>

0 comments on commit 8addc32

Please sign in to comment.