这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Action/CriteriaUpdateAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using XiboClient.Control;

namespace XiboClient.Action
{
internal class CriteriaUpdateAction : PlayerActionInterface
{
public const string Name = "criteriaUpdate";
public List<CriteriaRequest> Items { get; set; }

public CriteriaUpdateAction() {
Items = new List<CriteriaRequest>();
}

public string GetActionName()
{
return Name;
}
}
}
23 changes: 21 additions & 2 deletions Action/XmrSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand All @@ -21,11 +21,14 @@
using NetMQ;
using NetMQ.Sockets;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Crypto;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Windows.Markup;
using XiboClient.Control;
using XiboClient.Log;
using XiboClient.Logic;

Expand Down Expand Up @@ -265,6 +268,22 @@ private void processMessage(NetMQMessage message, AsymmetricCipherKeyPair rsaKey
OnAction?.Invoke(action);
break;

case "criteriaUpdate":
// Process into a CriteriaUpdateAction
var update = JsonConvert.DeserializeObject<JObject>(opened);
var updateAction = new CriteriaUpdateAction();
foreach (var item in update["criteriaUpdates"])
{
updateAction.Items.Add(new CriteriaRequest
{
metric = item["metric"].ToString(),
value = item["value"].ToString(),
ttl = int.Parse(item["ttl"].ToString())
});
}
OnAction?.Invoke(updateAction);
break;

default:
Trace.WriteLine(new LogMessage("XmrSubscriber - Run", "Unknown Message: " + action.action), LogType.Info.ToString());
break;
Expand Down
73 changes: 73 additions & 0 deletions Control/CriteriaController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using EmbedIO.Routing;
using EmbedIO;
using EmbedIO.WebApi;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace XiboClient.Control
{
internal class CriteriaController : WebApiController
{
private EmbeddedServer _parent;

public CriteriaController(EmbeddedServer parent)
{
_parent = parent;
}

/// <summary>
/// Trigger some action.
/// </summary>
[Route(HttpVerbs.Post, "/")]
public async void Criteria()
{
try
{
var resolvedItems = new List<CriteriaRequest>();
var data = await HttpContext.GetRequestBodyAsStringAsync();
var items = JsonConvert.DeserializeObject<JArray>(data);
foreach (var item in items.Children())
{
resolvedItems.Add(new CriteriaRequest
{
metric = item["metric"].ToString(),
value = item["value"].ToString(),
ttl = int.Parse(item["ttl"].ToString())
});
}
_parent.Criteria(resolvedItems);
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("CriteriaController", "Criteria: unable to parse request: " + e.Message), LogType.Error.ToString());
}
}
}
}
36 changes: 36 additions & 0 deletions Control/CriteriaRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XiboClient.Control
{
internal class CriteriaRequest
{
public string metric { get; set; }
public string value { get; set; }
public int ttl { get; set; }
}
}
20 changes: 16 additions & 4 deletions Control/EmbeddedServer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2021 Xibo Signage Ltd
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand All @@ -24,9 +24,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Documents;

namespace XiboClient.Control
{
Expand All @@ -46,6 +44,9 @@ class EmbeddedServer
public delegate void OnDurationReceivedDelegate(string operation, int sourceId, int duration);
public event OnDurationReceivedDelegate OnDurationReceived;

public delegate void OnCriteriaReceivedDelegate(List<CriteriaRequest> items);
public event OnCriteriaReceivedDelegate OnCriteriaReceived;

/// <summary>
/// Stops the thread
/// </summary>
Expand Down Expand Up @@ -118,6 +119,8 @@ private WebServer CreateWebServer(string url)
.WithController(() => new DurationController(this)))
.WithWebApi("/fault", m => m
.WithController(() => new FaultController()))
.WithWebApi("/criteria", m => m
.WithController(() => new CriteriaController(this)))
.WithModule(new RestrictiveFileModule("/", new FileSystemProvider(ApplicationSettings.Default.LibraryPath, false), paths), m => m
.ContentCaching = false);

Expand All @@ -143,5 +146,14 @@ public void Duration(string operation, int sourceId, int duration)
{
OnDurationReceived?.Invoke(operation, sourceId, duration);
}

/// <summary>
/// Criteria update
/// </summary>
/// <param name="items"></param>
public void Criteria(List<CriteriaRequest> items)
{
OnCriteriaReceived?.Invoke(items);
}
}
}
4 changes: 2 additions & 2 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2024 Xibo Signage Ltd
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
Expand Down Expand Up @@ -52,7 +52,7 @@ private static readonly Lazy<ApplicationSettings>
/// </summary>
private List<string> ExcludedProperties;

public string ClientVersion { get; } = "4 R405.0";
public string ClientVersion { get; } = "4 R405.3";
public string Version { get; } = "7";
public int ClientCodeVersion { get; } = 405;

Expand Down
45 changes: 45 additions & 0 deletions Logic/Criteria.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XiboClient.Logic
{
internal class Criteria
{
public string Value;
private readonly DateTime _expiry;

public Criteria(string value, int ttl)
{
Value = value;
_expiry = DateTime.Now.AddSeconds(ttl);
}

public bool IsExpired()
{
return _expiry < DateTime.Now;
}
}
}
Loading