private void HandleBulbGroupsPacket(IBulb bulb, AnswerPacketBase packet) { var lightStatus = packet as LightStatus; var tags = packet as Tags; if (tags != null || lightStatus != null) { var bitmask = lightStatus != null ? lightStatus.Bitmask : tags.Bitmask; var groupBitmasks = bitmask.GetGroupTags().ToList(); foreach (var groupBitmask in groupBitmasks) { BulbGroup group; if (!_groups.TryGetValue(groupBitmask, out group)) { lock (_groupCollectionLock) { if (!_groups.TryGetValue(groupBitmask, out group)) { group = CreateGroup(groupBitmask); } } } group.Add(bulb); if (string.IsNullOrEmpty(group.Name)) { var getTagLabels = (GetTagLabels)PacketFactory.GetCommand(CommandType.GetTagLabels); getTagLabels.Init(groupBitmask); SendCommand(bulb, getTagLabels); } } } }
/// <summary> /// Search for bulbs within the mesh network of the given gateway. /// </summary> public static void ScanGateway(this ILifxNetwork network, IGateway gateway) { var command = PacketFactory.GetCommand(CommandType.GetLightState); ((LifxNetwork)network).SendCommand(gateway, command); }