1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-12 17:48:31 +00:00
RGB.NET/RGB.NET.Devices.SoIP/Server/SoIPServerUpdateQueue.cs

55 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
using SimpleTCP;
namespace RGB.NET.Devices.SoIP.Server
{
/// <inheritdoc />
/// <summary>
/// Represents the update-queue performing updates for E131-DMX devices.
/// </summary>
public class SoIPServerUpdateQueue : UpdateQueue
{
#region Properties & Fields
private readonly SimpleTcpServer _tcpServer;
#endregion
#region Constructors
/// <inheritdoc />
/// <summary>
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.SoIP.Server.SoIPServerUpdateQueue" /> class.
/// </summary>
/// <param name="updateTrigger">The update trigger used by this queue.</param>
/// <param name="tcpServer">The hostname of the device this queue is performing updates for.</param>
public SoIPServerUpdateQueue(IDeviceUpdateTrigger updateTrigger, SimpleTcpServer tcpServer)
: base(updateTrigger)
{
this._tcpServer = tcpServer;
}
#endregion
#region Methods
/// <inheritdoc />
protected override void Update(Dictionary<object, Color> dataSet)
{
if ((dataSet != null) && (dataSet.Count > 0))
{
string m = GetLedString(dataSet);
_tcpServer.BroadcastLine(m);
Console.WriteLine("send " + m);
}
}
private string GetLedString(Dictionary<object, Color> dataSet) => string.Join(";", dataSet.Select(x => x.Key.ToString() + "|" + x.Value.AsARGBHexString()));
#endregion
}
}