mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-02 14:24:59 +00:00
feat: enable subscription logic for messengers
In order to help control traffic over the websocket, a subscription feature has been added: * A config option, `enableMessengerSubscriptions` has been added * When true, the MessengerBase class will assume that any message sent using the `PostStatusMessage` that has a valid client ID wants to send any subsequent unsolicited updates to that same client * The client's ID will be added a list of subscribed client IDs * Any subsequent messages sent using the `PostStatusMessage` methods that have a null clientId will ONLY be sent to subscribed clients * When a client disconnects, it will be removed from the list of subscribed clients This should cut down drastically on the traffic to the UI, especially when combined with requesting partial status updates from a device rather than the entire state.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IMobileControlMessenger
|
||||
/// </summary>
|
||||
public interface IMobileControlMessengerWithSubscriptions : IMobileControlMessenger
|
||||
{
|
||||
/// <summary>
|
||||
/// Unsubscribe a client from this messenger
|
||||
/// </summary>
|
||||
/// <param name="clientId"></param>
|
||||
void UnsubscribeClient(string clientId);
|
||||
|
||||
/// <summary>
|
||||
/// Register this messenger with the AppServerController
|
||||
/// </summary>
|
||||
/// <param name="appServerController">parent for this messenger</param>
|
||||
/// <param name="enableMessengerSubscriptions">Enable messenger subscriptions</param>
|
||||
void RegisterWithAppServer(IMobileControl appServerController, bool enableMessengerSubscriptions);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user