public static void ChangeReceiverChannel(int receiverId, int channel) { var receiver = Receivers.FirstOrDefault(r => r.Id == receiverId); if (receiver == null) { return; } var emittersOnChannel = Emitters.Where(e => e.EmitChannel == channel).ToList(); var signal = emittersOnChannel.Any() ? emittersOnChannel.First().Signal : 0; NotifyReceivers(channel, signal); receiver.Channel = channel; }
public static void ChangeEmitterChannel(int emitterId, int channel) { var emitter = Emitters.FirstOrDefault(e => e.Id == emitterId); if (emitter == null) { return; } var othersOnChannel = Emitters.Where(e => e.Id != emitterId && e.EmitChannel == emitter.EmitChannel).ToList(); var leaveSignal = othersOnChannel.Any() ? othersOnChannel.First().Signal : 0; NotifyReceivers(emitter.EmitChannel, leaveSignal); emitter.EmitChannel = channel; NotifyReceivers(emitter.EmitChannel, emitter.Signal); }