diff --git a/Notifications.Client/NotificationManager.cs b/Notifications.Client/NotificationManager.cs
new file mode 100644
index 0000000..e1f917d
--- /dev/null
+++ b/Notifications.Client/NotificationManager.cs
@@ -0,0 +1,22 @@
+using JetBrains.Annotations;
+using NFive.Notifications.Shared;
+using NFive.SDK.Client.Communications;
+
+namespace NFive.Notifications.Client
+{
+ [PublicAPI]
+ public class NotificationManager
+ {
+ private readonly ICommunicationManager comms;
+
+ public NotificationManager(ICommunicationManager comms)
+ {
+ this.comms = comms;
+ }
+
+ public void Show(Notification notification)
+ {
+ this.comms.Event(NotificationsEvents.ShowNotification).ToClient().Emit(notification);
+ }
+ }
+}
diff --git a/Notifications.Client/Notifications.Client.csproj b/Notifications.Client/Notifications.Client.csproj
index 2c9fd4b..b89f0f3 100644
--- a/Notifications.Client/Notifications.Client.csproj
+++ b/Notifications.Client/Notifications.Client.csproj
@@ -62,6 +62,7 @@
+
diff --git a/Notifications.Client/NotificationsService.cs b/Notifications.Client/NotificationsService.cs
index f66d3a0..a5ae584 100644
--- a/Notifications.Client/NotificationsService.cs
+++ b/Notifications.Client/NotificationsService.cs
@@ -1,4 +1,3 @@
-using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using NFive.Notifications.Client.Overlays;
@@ -30,15 +29,15 @@ public override async Task Started()
this.overlay = new NotificationsOverlay(this.OverlayManager, this.config);
// Listen to server notifications
- this.Comms.Event(NotificationsEvents.ShowNotification).FromServer().On((e, text, type, timeout) =>
+ this.Comms.Event(NotificationsEvents.ShowNotification).FromServer().On((e, notification) =>
{
- this.overlay.Notify(text, type, timeout);
+ this.overlay.Notify(notification);
});
// Listen to client notifications
- this.Comms.Event(NotificationsEvents.ShowNotification).FromClient().On((e, text, type, timeout) =>
+ this.Comms.Event(NotificationsEvents.ShowNotification).FromClient().On((e, notification) =>
{
- this.overlay.Notify(text, type, timeout);
+ this.overlay.Notify(notification);
});
}
}
diff --git a/Notifications.Client/Overlays/NotificationsOverlay.cs b/Notifications.Client/Overlays/NotificationsOverlay.cs
index 95843ad..57bf674 100644
--- a/Notifications.Client/Overlays/NotificationsOverlay.cs
+++ b/Notifications.Client/Overlays/NotificationsOverlay.cs
@@ -1,4 +1,3 @@
-using System;
using NFive.Notifications.Shared;
using NFive.SDK.Client.Interface;
@@ -24,13 +23,13 @@ public NotificationsOverlay(IOverlayManager manager, Configuration configuration
timeout = this.config.DefaultTimeout.TotalMilliseconds
};
- public void Notify(string text, string type = null, TimeSpan? timeout = null)
+ public void Notify(Notification notification)
{
Emit("notify", new
{
- text,
- type,
- timeout?.TotalMilliseconds
+ text = notification.Text,
+ type = notification.Type,
+ timeout = notification.Timeout?.TotalMilliseconds
});
}
}
diff --git a/Notifications.Shared/Notification.cs b/Notifications.Shared/Notification.cs
new file mode 100644
index 0000000..5637fc3
--- /dev/null
+++ b/Notifications.Shared/Notification.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace NFive.Notifications.Shared
+{
+ public class Notification
+ {
+ public string Text { get; set; }
+
+ public string Type { get; set; }
+
+ public TimeSpan? Timeout { get; set; }
+ }
+}
diff --git a/Notifications.Shared/Notifications.Shared.csproj b/Notifications.Shared/Notifications.Shared.csproj
index f66f94c..22d0379 100644
--- a/Notifications.Shared/Notifications.Shared.csproj
+++ b/Notifications.Shared/Notifications.Shared.csproj
@@ -52,6 +52,7 @@
+
diff --git a/nfive.yml b/nfive.yml
index 19b2c9d..f92da04 100644
--- a/nfive.yml
+++ b/nfive.yml
@@ -1,5 +1,5 @@
name: NFive/plugin-notifications
-version: 0.1.0
+version: 0.2.0
description: Simple client notifications
author: NFive
license: LGPL-3.0-or-later