-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d66b7a
commit dc5e5c3
Showing
3 changed files
with
74 additions
and
32 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 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,70 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using NvxEpi.Devices; | ||
using NvxEpi.Services.Feedback; | ||
using PepperDash.Essentials.AppServer.Messengers; | ||
using PepperDash.Essentials.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NvxEpi.McMessengers | ||
{ | ||
public class EndpointInfoMessenger:MessengerBase | ||
{ | ||
private readonly NvxBaseDevice device; | ||
|
||
private readonly StringFeedback deviceNameFeedback; | ||
public EndpointInfoMessenger(string key, string path, NvxBaseDevice device): base(key, path, device) | ||
{ | ||
this.device = device; | ||
|
||
deviceNameFeedback = device.Feedbacks.FirstOrDefault(fb => fb.Key == DeviceNameFeedback.Key) as StringFeedback; | ||
|
||
if (deviceNameFeedback == null) | ||
{ | ||
return; | ||
} | ||
|
||
deviceNameFeedback.OutputChange += SendUpdate; | ||
} | ||
|
||
protected override void RegisterActions() | ||
{ | ||
base.RegisterActions(); | ||
|
||
AddAction("/fullStatus", SendFullStatus); | ||
|
||
} | ||
|
||
private void SendFullStatus(string id, JToken content) | ||
{ | ||
PostStatusMessage(new EndpointInfoStateMessage | ||
{ | ||
DeviceName = deviceNameFeedback?.StringValue ?? string.Empty | ||
}); | ||
} | ||
|
||
private void SendUpdate(object sender, FeedbackEventArgs args) | ||
{ | ||
PostStatusMessage(JToken.FromObject(new EndpointInfoUpdateMessage | ||
{ | ||
DeviceName = deviceNameFeedback?.StringValue ?? string.Empty | ||
})); | ||
} | ||
} | ||
|
||
public class EndpointInfoStateMessage : DeviceStateMessageBase | ||
{ | ||
[JsonProperty("friendlyName")] | ||
public string DeviceName { get; set; } | ||
} | ||
|
||
public class EndpointInfoUpdateMessage | ||
{ | ||
[JsonProperty("friendlyName")] | ||
public string DeviceName { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.