Skip to content

Commit

Permalink
Merge pull request #114 from dasgarner/feature/wpf
Browse files Browse the repository at this point in the history
WPF Player
  • Loading branch information
dasgarner authored Mar 9, 2020
2 parents f104c73 + ef6f708 commit 13365b0
Show file tree
Hide file tree
Showing 112 changed files with 5,537 additions and 7,439 deletions.
2 changes: 0 additions & 2 deletions Action/Command.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace XiboClient.Logic
{
Expand Down
3 changes: 0 additions & 3 deletions Action/LayoutChangePlayerAction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiboClient.Action
{
Expand Down
3 changes: 0 additions & 3 deletions Action/OverlayLayoutPlayerAction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiboClient.Action
{
Expand Down
3 changes: 0 additions & 3 deletions Action/PlayerAction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiboClient.Action
{
Expand Down
3 changes: 0 additions & 3 deletions Action/PlayerActionInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiboClient.Action
{
Expand Down
9 changes: 2 additions & 7 deletions Action/RevertToSchedulePlayerAction.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiboClient.Action
namespace XiboClient.Action
{
class RevertToSchedulePlayerAction : PlayerActionInterface
{
public const string Name = "revertToSchedule";

public string GetActionName()
{
return Name;
Expand Down
2 changes: 0 additions & 2 deletions Action/Rs232Command.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Ports;
using System.Linq;
using System.Text;

namespace XiboClient.Logic
{
Expand Down
3 changes: 0 additions & 3 deletions Action/ScheduleCommand.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace XiboClient.Logic
{
Expand Down
100 changes: 45 additions & 55 deletions Action/XmrSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using XiboClient.Action;
using XiboClient.Log;
Expand Down Expand Up @@ -42,18 +40,6 @@ public HardwareKey HardwareKey
}
private HardwareKey _hardwareKey;

/// <summary>
/// Client Info Form
/// </summary>
public ClientInfo ClientInfoForm
{
set
{
_clientInfoForm = value;
}
}
private ClientInfo _clientInfoForm;

/// <summary>
/// The MQ Poller
/// </summary>
Expand Down Expand Up @@ -81,52 +67,59 @@ public void Run()
_manualReset.Reset();

// Check we have an address to connect to.
if (string.IsNullOrEmpty(ApplicationSettings.Default.XmrNetworkAddress))
throw new Exception("Empty XMR Network Address");

// Cache the address for this socket (the setting may change outside).
_address = ApplicationSettings.Default.XmrNetworkAddress;

// Get the Private Key
AsymmetricCipherKeyPair rsaKey = _hardwareKey.getXmrKey();

// Connect to XMR
try
if (!string.IsNullOrEmpty(ApplicationSettings.Default.XmrNetworkAddress) && ApplicationSettings.Default.XmrNetworkAddress != "DISABLED")
{
// Create a Poller
_poller = new NetMQPoller();
// Cache the address for this socket (the setting may change outside).
_address = ApplicationSettings.Default.XmrNetworkAddress;

// Get the Private Key
AsymmetricCipherKeyPair rsaKey = _hardwareKey.getXmrKey();

// Create a Socket
using (SubscriberSocket socket = new SubscriberSocket())
// Connect to XMR
try
{
// Options
socket.Options.ReconnectInterval = TimeSpan.FromSeconds(5);
socket.Options.Linger = TimeSpan.FromSeconds(0);
// Create a Poller
_poller = new NetMQPoller();

// Create a Socket
using (SubscriberSocket socket = new SubscriberSocket())
{
// Options
socket.Options.ReconnectInterval = TimeSpan.FromSeconds(5);
socket.Options.Linger = TimeSpan.FromSeconds(0);

// Bind
socket.Connect(ApplicationSettings.Default.XmrNetworkAddress);
socket.Subscribe("H");
socket.Subscribe(_hardwareKey.Channel);
// Bind
socket.Connect(ApplicationSettings.Default.XmrNetworkAddress);
socket.Subscribe("H");
socket.Subscribe(_hardwareKey.Channel);

// Add Socket to Poller
_poller.Add(socket);
// Add Socket to Poller
_poller.Add(socket);

// Bind to the receive ready event
socket.ReceiveReady += _socket_ReceiveReady;
// Bind to the receive ready event
socket.ReceiveReady += _socket_ReceiveReady;

// Notify
_clientInfoForm.XmrSubscriberStatus = "Connected to " + ApplicationSettings.Default.XmrNetworkAddress + ". Waiting for messages.";
// Notify
ClientInfo.Instance.XmrSubscriberStatus = "Connected to " + ApplicationSettings.Default.XmrNetworkAddress + ". Waiting for messages.";

// Sit and wait, processing messages, indefinitely or until we are interrupted.
_poller.Run();
// Sit and wait, processing messages, indefinitely or until we are interrupted.
_poller.Run();
}
}
finally
{
_poller.Dispose();
}

Trace.WriteLine(new LogMessage("XmrSubscriber - Run", "Socket Disconnected, waiting to reconnect."), LogType.Info.ToString());

// Update status
ClientInfo.Instance.XmrSubscriberStatus = "Disconnected, waiting to reconnect, last activity: " + LastHeartBeat.ToString();
}
finally
else
{
_poller.Dispose();
ClientInfo.Instance.XmrSubscriberStatus = "Not configured or Disabled";
}

Trace.WriteLine(new LogMessage("XmrSubscriber - Run", "Socket Disconnected, waiting to reconnect."), LogType.Info.ToString());
}
catch (TerminatingException terminatingEx)
{
Expand All @@ -135,12 +128,9 @@ public void Run()
catch (Exception e)
{
Trace.WriteLine(new LogMessage("XmrSubscriber - Run", "Unable to Subscribe: " + e.Message), LogType.Info.ToString());
_clientInfoForm.XmrSubscriberStatus = e.Message;
ClientInfo.Instance.XmrSubscriberStatus = e.Message;
}

// Update status
_clientInfoForm.XmrSubscriberStatus = "Disconnected, waiting to reconnect, last activity: " + LastHeartBeat.ToString();

// Sleep for 60 seconds.
_manualReset.WaitOne(60 * 1000);
}
Expand Down Expand Up @@ -169,7 +159,7 @@ private void _socket_ReceiveReady(object sender, NetMQSocketEventArgs e)
// Log this message, but dont abort the thread
Trace.WriteLine(new LogMessage("XmrSubscriber - _socket_ReceiveReady", "Exception in Run: " + ex.Message), LogType.Error.ToString());
Trace.WriteLine(new LogMessage("XmrSubscriber - _socket_ReceiveReady", e.ToString()), LogType.Audit.ToString());
_clientInfoForm.XmrSubscriberStatus = "Error. " + ex.Message;
ClientInfo.Instance.XmrSubscriberStatus = "Error. " + ex.Message;
}
}

Expand All @@ -182,7 +172,7 @@ private void processMessage(NetMQMessage message, AsymmetricCipherKeyPair rsaKey
string statusMessage = "Connected (" + ApplicationSettings.Default.XmrNetworkAddress + "), last activity: " + DateTime.Now.ToString();

// Write this out to a log
_clientInfoForm.XmrSubscriberStatus = statusMessage;
ClientInfo.Instance.XmrSubscriberStatus = statusMessage;
Trace.WriteLine(new LogMessage("XmrSubscriber - Run", statusMessage), LogType.Audit.ToString());

// Deal with heart beat
Expand Down Expand Up @@ -254,7 +244,7 @@ private void processMessage(NetMQMessage message, AsymmetricCipherKeyPair rsaKey

case "screenShot":
ScreenShot.TakeAndSend();
_clientInfoForm.notifyStatusToXmds();
ClientInfo.Instance.NotifyStatusToXmds();
break;

default:
Expand Down
8 changes: 8 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="XiboClient.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XiboClient">
<Application.Resources>

</Application.Resources>
</Application>
Loading

0 comments on commit 13365b0

Please sign in to comment.