Skip to content

Commit

Permalink
add some events
Browse files Browse the repository at this point in the history
  • Loading branch information
HandyS11 committed May 28, 2024
1 parent 84526a6 commit a37a033
Show file tree
Hide file tree
Showing 10 changed files with 454 additions and 298 deletions.
24 changes: 11 additions & 13 deletions RustPlusApi/Examples/Fcm/FcmListener/Program.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
using Newtonsoft.Json;

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

var credentials = new Credentials
{
Keys = new Keys
{
PrivateKey = "PNo-juMIoy8nh45ap7CcOjmvCcXG71zxo1Kf6sG75yI",
PublicKey = "BMLRwfGJ3poc2ih6eIQpf-7xwkP9z98K8vh-bWzxypDERTUIyAqpulccHR6WBVP8jgoecNtYePTYvSc-sHGhWcY",
AuthSecret = "3_stBv0R105hCQJgJ_Oqag",
PrivateKey = "",
PublicKey = "",
AuthSecret = "",
},
Fcm = new FcmCredentials
{
Token = "de0gThSZW5A:APA91bEpz3S-tIVNV4uoKKNc_UCA_8tcg5lxEWiXkx-zFb0-H6FG5ltQvkGYzfxcfm3GxNihFgfRvH7Ps0_IdvRpOvjVREsm8uJwhkt8ztaoOZ886osG-bvGGVfV2jt1rPDG1_22NoMm",
PushSet = "dEhc-sLR9LY",
Token = "",
PushSet = "",
},
Gcm = new GcmCredentials
{
Token = "ctMfS0V2BB0:APA91bG5LKmV_pe27v7Drm4OBYMkZS8eItKHUX-wG5eUw1WmKFTSkwYr4hw43AQmP7oBwHzeKbMRDEmaml0lh2CBvh0s3pXxrDSng6au3t-iE1FkEhpBOwaDh74Hk2z6Y8GcFTcaPsA2",
AndroidId = 5198350057269518718,
SecurityToken = 726893779159876265,
AppId = "wp:receiver.push.com#46616054-1728-4be7-9dc6-740f3e76d9f4",
Token = "",
AndroidId = 0,
SecurityToken = 0,
AppId = "",
}
};

var listener = new FcmListener(credentials);

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

listener.ErrorOccurred += (_, error) =>
Expand Down
9 changes: 9 additions & 0 deletions RustPlusApi/RustPlusApi.Fcm/Data/Events/AlarmEventArg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace RustPlusApi.Fcm.Data.Events
{
public class AlarmEventArg
{
public Guid ServerId { get; set; }
public string Title { get; set; } = null!;
public string Message { get; set; } = null!;
}
}
9 changes: 9 additions & 0 deletions RustPlusApi/RustPlusApi.Fcm/Data/Events/EntityEventArg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace RustPlusApi.Fcm.Data.Events
{
public class EntityEventArg
{
public int EntityType { get; set; }
public int EntityId { get; set; }
public string EntityName { get; set; } = null!;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using static RustPlusApi.Fcm.Data.Constants;

namespace RustPlusApi.Fcm.Utils
namespace RustPlusApi.Fcm.Data.Events
{
internal class MessageEventArgs : EventArgs
{
Expand Down
9 changes: 9 additions & 0 deletions RustPlusApi/RustPlusApi.Fcm/Data/Events/ServerEventArg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace RustPlusApi.Fcm.Data.Events
{
public class ServerEventArg
{
public Guid Id { get; set; }
public string Name { get; set; } = null!;
}
}
12 changes: 12 additions & 0 deletions RustPlusApi/RustPlusApi.Fcm/Data/Events/ServerFullEventArg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace RustPlusApi.Fcm.Data.Events
{
public class ServerFullEventArg : ServerEventArg
{
public string Ip { get; set; } = null!;
public int Port { get; set; }
public string Desc { get; set; } = null!;
public int Logo { get; set; }
public int Img { get; set; }
public string Url { get; set; } = null!;
}
}
36 changes: 18 additions & 18 deletions RustPlusApi/RustPlusApi.Fcm/Data/FcmMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ namespace RustPlusApi.Fcm.Data
{
public class FcmMessage
{
public Data Data { get; set; } = null!;
public string From { get; set; } = null!;
public Guid FcmMessageId { get; set; }
public string Priority { get; set; } = null!;
public string FcmMessageId { get; set; } = null!;
public long From { get; set; }
public MessageData Data { get; set; } = null!;
}

public class Data
public class MessageData
{
public Guid ProjectId { get; set; }
public string ChannelId { get; set; } = null!;
public string Title { get; set; } = null!;
public string Message { get; set; } = null!;
public string ExperienceId { get; set; } = null!;
public string ScopeKey { get; set; } = null!;
[JsonConverter(typeof(BodyConverter))]
public Body Body { get; set; } = null!;
public string Message { get; set; } = null!;
public string Title { get; set; } = null!;
public string ProjectId { get; set; } = null!;
public string ChannelId { get; set; } = null!;
}

public class Body
{
public string Img { get; set; } = null!;
public string EntityType { get; set; } = null!;
public Guid Id { get; set; }
public string Ip { get; set; } = null!;
public string EntityId { get; set; } = null!;
public string Type { get; set; } = null!;
public int Port { get; set; }
public string Name { get; set; } = null!;
public string Desc { get; set; } = null!;
public int Logo { get; set; }
public int Img { get; set; }
public string Url { get; set; } = null!;
public ulong PlayerId { get; set; }
public string PlayerToken { get; set; } = null!;
public string Port { get; set; } = null!;
public string Type { get; set; } = null!;
public int? EntityType { get; set; }
public int? EntityId { get; set; }
public string EntityName { get; set; } = null!;
public string Name { get; set; } = null!;
public string Logo { get; set; } = null!;
public string Id { get; set; } = null!;
public string Desc { get; set; } = null!;
public string PlayerId { get; set; } = null!;
}
}
Loading

0 comments on commit a37a033

Please sign in to comment.