/// <inheritdoc /> public override async Task <ILifxColorMultiZoneState> GetMultizoneState(ushort startAt = 0, ushort length = 255, int?timeoutMs = null, CancellationToken cancellationToken = default) { MultizoneState state = new MultizoneState(length) { Index = startAt, }; Messages.GetColorZones getColorZones = new Messages.GetColorZones() { StartIndex = (byte)startAt, EndIndex = (byte)Math.Min(255, startAt + length), }; IReadOnlyCollection <LifxMessage> responses = await this.Lifx.SendWithMultipleResponse <LifxMessage>(this, getColorZones, timeoutMs, cancellationToken); foreach (LifxMessage response in responses) { if (response is Messages.StateZone singleZone) { // Copy zone count property state.ZoneCount = singleZone.ZoneCount; // Copy color state.Colors[singleZone.Index - startAt] = singleZone; } else if (response is Messages.StateMultiZone multiZone) { // Copy zone count property state.ZoneCount = multiZone.ZoneCount; // Keep track of index int ctr = 0; // Copy all colors foreach (ILifxHsbkColor color in multiZone.Colors) { state.Colors[multiZone.Index - startAt + ctr++] = color; } } else { // TODO: Exception? } } return(state); }
/// <inheritdoc /> public override async Task <ILifxColorMultiZoneState> GetMultizoneState(ushort startAt = 0, ushort length = 255, int?timeoutMs = null, CancellationToken cancellationToken = default) { Messages.GetExtendedColorZones getExtendedColorZones = new Messages.GetExtendedColorZones(); Messages.StateExtendedColorZones extendedColorZones = await this.Lifx.SendWithResponse <Messages.StateExtendedColorZones>(this, getExtendedColorZones, timeoutMs, cancellationToken); // Create state ILifxColorMultiZoneState state = new MultizoneState(length) { ZoneCount = extendedColorZones.ZoneCount, Index = startAt, }; // Keep track of index int ctr = 0; foreach (ILifxHsbkColor color in extendedColorZones.Colors) { state.Colors[ctr++] = color; } return(state); }