Skip to content

Commit

Permalink
Merge refacto/cleanFcm into develop (#18)
Browse files Browse the repository at this point in the history
* clean-up code
* add examples
  • Loading branch information
HandyS11 authored Jun 3, 2024
1 parent 1d15c66 commit b14d652
Show file tree
Hide file tree
Showing 37 changed files with 610 additions and 1,508 deletions.
28 changes: 14 additions & 14 deletions RustPlusApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RustPlusApi.Fcm", "RustPlus
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Fcm", "Fcm", "{A4EF8656-723B-4E2E-9457-57DCB24CB409}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FcmRegister", "RustPlusApi\Examples\Fcm\FcmRegister\FcmRegister.csproj", "{FF9758F9-2500-4CE1-AACE-8C67134046F4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FcmListener", "RustPlusApi\Examples\Fcm\FcmListener\FcmListener.csproj", "{5B175E6B-4118-422D-BF08-F94B7337D229}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTeamChat", "RustPlusApi\Examples\GetTeamChat\GetTeamChat.csproj", "{1A186504-8461-4F19-BDC5-C3DB90A554D6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PromoteToLeader", "RustPlusApi\Examples\PromoteToLeader\PromoteToLeader.csproj", "{3DE93E0D-DAF5-48E7-A353-BD99ABB942DE}"
Expand Down Expand Up @@ -99,6 +95,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StrobeSmartSwitch", "RustPl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SendTeamMessage", "RustPlusApi\Examples\SendTeamMessage\SendTeamMessage.csproj", "{83CC5666-ABBF-4057-BCDA-66A6F1881A7E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RustPlusFcmListenerClient", "RustPlusApi\Examples\Fcm\RustPlusFcmListenerClient\RustPlusFcmListenerClient.csproj", "{89321BD6-3D4E-479B-A795-B30A6898E7BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RustPlusFcmListener", "RustPlusApi\Examples\Fcm\RustPlusFcmListener\RustPlusFcmListener.csproj", "{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -137,14 +137,6 @@ Global
{CFDFB335-A783-4F82-8094-3ED14E3EBC49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFDFB335-A783-4F82-8094-3ED14E3EBC49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFDFB335-A783-4F82-8094-3ED14E3EBC49}.Release|Any CPU.Build.0 = Release|Any CPU
{FF9758F9-2500-4CE1-AACE-8C67134046F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF9758F9-2500-4CE1-AACE-8C67134046F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF9758F9-2500-4CE1-AACE-8C67134046F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF9758F9-2500-4CE1-AACE-8C67134046F4}.Release|Any CPU.Build.0 = Release|Any CPU
{5B175E6B-4118-422D-BF08-F94B7337D229}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B175E6B-4118-422D-BF08-F94B7337D229}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B175E6B-4118-422D-BF08-F94B7337D229}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B175E6B-4118-422D-BF08-F94B7337D229}.Release|Any CPU.Build.0 = Release|Any CPU
{1A186504-8461-4F19-BDC5-C3DB90A554D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A186504-8461-4F19-BDC5-C3DB90A554D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A186504-8461-4F19-BDC5-C3DB90A554D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -285,6 +277,14 @@ Global
{83CC5666-ABBF-4057-BCDA-66A6F1881A7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83CC5666-ABBF-4057-BCDA-66A6F1881A7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83CC5666-ABBF-4057-BCDA-66A6F1881A7E}.Release|Any CPU.Build.0 = Release|Any CPU
{89321BD6-3D4E-479B-A795-B30A6898E7BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89321BD6-3D4E-479B-A795-B30A6898E7BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89321BD6-3D4E-479B-A795-B30A6898E7BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89321BD6-3D4E-479B-A795-B30A6898E7BF}.Release|Any CPU.Build.0 = Release|Any CPU
{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -297,8 +297,6 @@ Global
{E9F90342-34DE-4166-9769-483A3FA1F144} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{DD34FAE8-30AA-4787-A6D1-77C330A0928F} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{A4EF8656-723B-4E2E-9457-57DCB24CB409} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{FF9758F9-2500-4CE1-AACE-8C67134046F4} = {A4EF8656-723B-4E2E-9457-57DCB24CB409}
{5B175E6B-4118-422D-BF08-F94B7337D229} = {A4EF8656-723B-4E2E-9457-57DCB24CB409}
{1A186504-8461-4F19-BDC5-C3DB90A554D6} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{3DE93E0D-DAF5-48E7-A353-BD99ABB942DE} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{D39626D0-079C-40C6-A260-09852E11C70A} = {BC948ADE-1674-4955-B27C-F0E96100978E}
Expand Down Expand Up @@ -335,6 +333,8 @@ Global
{9B61744E-51F4-4EBC-B42C-3EABE7CC7487} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{EE0FE493-5230-485F-8D45-B5887FA50D86} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{83CC5666-ABBF-4057-BCDA-66A6F1881A7E} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{89321BD6-3D4E-479B-A795-B30A6898E7BF} = {A4EF8656-723B-4E2E-9457-57DCB24CB409}
{4D0DCF6E-ABA1-407F-B0C9-59306E7FC8CA} = {A4EF8656-723B-4E2E-9457-57DCB24CB409}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4B4251F-ADA4-418D-95B5-27BA99A307A3}
Expand Down
38 changes: 0 additions & 38 deletions RustPlusApi/Examples/Fcm/FcmListener/Program.cs

This file was deleted.

14 changes: 0 additions & 14 deletions RustPlusApi/Examples/Fcm/FcmRegister/FcmRegister.csproj

This file was deleted.

10 changes: 0 additions & 10 deletions RustPlusApi/Examples/Fcm/FcmRegister/Program.cs

This file was deleted.

75 changes: 75 additions & 0 deletions RustPlusApi/Examples/Fcm/RustPlusFcmListener/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Newtonsoft.Json;

using RustPlusApi.Fcm;
using RustPlusApi.Fcm.Data;

using static __Constants.ExamplesConst;

var credentials = new Credentials
{
Keys = new Keys
{
PrivateKey = "",
PublicKey = "",
AuthSecret = "",
},
Gcm = new Gcm
{
AndroidId = 0,
SecurityToken = 0,
}
};

var listener = new RustPlusFcmListener(credentials);

listener.Connecting += (_, _) =>
{
Console.WriteLine($"[CONNECTING]: {DateTime.Now}");
};

listener.Connected += (_, _) =>
{
Console.WriteLine($"[CONNECTED]: {DateTime.Now}");
};

listener.SocketClosed += (_, _) =>
{
Console.WriteLine($"[SOCKET CLOSED]: {DateTime.Now}");
};

listener.ErrorOccurred += (_, error) =>
{
Console.WriteLine($"[ERROR]: {error}");
};

listener.Disconnecting += (_, _) =>
{
Console.WriteLine($"[DISCONNECTING]: {DateTime.Now}");
};

listener.Disconnected += (_, _) =>
{
Console.WriteLine($"[DISCONNECTED]: {DateTime.Now}");
};

/* Specials events */

listener.OnServerPairing += (_, pairing) =>
{
Console.WriteLine($"[SERVER PAIRING]:\n{JsonConvert.SerializeObject(pairing, JsonSettings)}");
};

listener.OnEntityParing += (_, pairing) =>
{
Console.WriteLine($"[ENTITY PAIRING]:\n{JsonConvert.SerializeObject(pairing, JsonSettings)}");
};

listener.OnAlarmTriggered += (_, alarm) =>
{
Console.WriteLine($"[ALARM TRIGGERED]:\n{JsonConvert.SerializeObject(alarm, JsonSettings)}");
};

await listener.ConnectAsync();

Console.ReadLine();
listener.Disconnect();
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.Fcm\RustPlusApi.Fcm.csproj" />
<ProjectReference Include="..\..\__Constants\__Constants.csproj" />
</ItemGroup>

</Project>
60 changes: 60 additions & 0 deletions RustPlusApi/Examples/Fcm/RustPlusFcmListenerClient/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using RustPlusApi.Fcm;
using RustPlusApi.Fcm.Data;
using RustPlusApi.Fcm.Extensions;

var credentials = new Credentials
{
Keys = new Keys
{
PrivateKey = "",
PublicKey = "",
AuthSecret = "",
},
Gcm = new Gcm
{
AndroidId = 0,
SecurityToken = 0,
}
};

var listener = new RustPlusFcmListenerClient(credentials);

listener.Connecting += (_, _) =>
{
Console.WriteLine($"[CONNECTING]: {DateTime.Now}");
};

listener.Connected += (_, _) =>
{
Console.WriteLine($"[CONNECTED]: {DateTime.Now}");
};

listener.NotificationReceived += (_, message) =>
{
Console.WriteLine($"[NOTIFICATION]: {DateTime.Now}:\n{message.ToFcmMessageString()}");
};

listener.SocketClosed += (_, _) =>
{
Console.WriteLine($"[SOCKET CLOSED]: {DateTime.Now}");
};

listener.ErrorOccurred += (_, error) =>
{
Console.WriteLine($"[ERROR]: {error}");
};

listener.Disconnecting += (_, _) =>
{
Console.WriteLine($"[DISCONNECTING]: {DateTime.Now}");
};

listener.Disconnected += (_, _) =>
{
Console.WriteLine($"[DISCONNECTED]: {DateTime.Now}");
};

await listener.ConnectAsync();

Console.ReadLine();
listener.Disconnect();
Loading

0 comments on commit b14d652

Please sign in to comment.