-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge refacto/cleanFcm into develop (#18)
* clean-up code * add examples
- Loading branch information
Showing
37 changed files
with
610 additions
and
1,508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
15 changes: 15 additions & 0 deletions
15
RustPlusApi/Examples/Fcm/RustPlusFcmListener/RustPlusFcmListener.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
60
RustPlusApi/Examples/Fcm/RustPlusFcmListenerClient/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
File renamed without changes.
Oops, something went wrong.