//send updated radio info back to DCS for ingame GUI private void SendRadioUpdateToDCS() { if (_dcsRadioUpdateSender == null) { _dcsRadioUpdateSender = new UdpClient { ExclusiveAddressUse = false, EnableBroadcast = true }; _dcsRadioUpdateSender.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _dcsRadioUpdateSender.ExclusiveAddressUse = false; } int clientCountIngame = 0; foreach (KeyValuePair <string, SRClient> kvp in _clients) { if (kvp.Value.IsIngame()) { clientCountIngame++; } } try { //get currently transmitting or receiving var combinedState = new CombinedRadioState() { RadioInfo = _clientStateSingleton.DcsPlayerRadioInfo, RadioSendingState = UdpVoiceHandler.RadioSendingState, RadioReceivingState = UdpVoiceHandler.RadioReceivingState, ClientCountConnected = _clients.Count, ClientCountIngame = clientCountIngame }; var message = JsonConvert.SerializeObject(combinedState, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) + "\n"; var byteData = Encoding.UTF8.GetBytes(message); //Logger.Info("Sending Update over UDP 7080 DCS - 7082 Flight Panels: \n"+message); _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _settings.GetNetworkSetting(SettingsKeys.OutgoingDCSUDPInfo))); //send to DCS _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _settings.GetNetworkSetting(SettingsKeys .OutgoingDCSUDPOther))); // send to Flight Control Panels } catch (Exception e) { Logger.Error(e, "Exception Sending DCS Radio Update Message"); } }
//send updated radio info back to DCS for ingame GUI private void SendRadioUpdateToDCS() { var host = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7080); if (_dcsRadioUpdateSender == null) { _dcsRadioUpdateSender = new UdpClient { ExclusiveAddressUse = false, EnableBroadcast = true }; _dcsRadioUpdateSender.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _dcsRadioUpdateSender.ExclusiveAddressUse = false; } try { //get currently transmitting or receiving var combinedState = new CombinedRadioState() { RadioInfo = _clientStateSingleton.DcsPlayerRadioInfo, RadioSendingState = TCPVoiceHandler.RadioSendingState, RadioReceivingState = TCPVoiceHandler.RadioReceivingState }; var byteData = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(combinedState, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) + "\n"); _dcsRadioUpdateSender.Send(byteData, byteData.Length, host); } catch (Exception e) { Logger.Error(e, "Exception Sending DCS Radio Update Message"); } }
//send updated radio info back to DCS for ingame GUI private void SendRadioUpdateToDCS() { if (_dcsRadioUpdateSender == null) { _dcsRadioUpdateSender = new UdpClient(); } try { var connectedClientsSingleton = ConnectedClientsSingleton.Instance; int[] tunedClients = new int[11]; if (_clientStateSingleton.IsConnected && _clientStateSingleton.DcsPlayerRadioInfo != null && _clientStateSingleton.DcsPlayerRadioInfo.IsCurrent()) { for (int i = 0; i < tunedClients.Length; i++) { var clientRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[i]; if (clientRadio.modulation != RadioInformation.Modulation.DISABLED) { tunedClients[i] = connectedClientsSingleton.ClientsOnFreq(clientRadio.freq, clientRadio.modulation); } } } //get currently transmitting or receiving var combinedState = new CombinedRadioState() { RadioInfo = _clientStateSingleton.DcsPlayerRadioInfo, RadioSendingState = _clientStateSingleton.RadioSendingState, RadioReceivingState = _clientStateSingleton.RadioReceivingState, ClientCountConnected = _clients.Total, TunedClients = tunedClients, }; var message = JsonConvert.SerializeObject(combinedState, new JsonSerializerSettings { // NullValueHandling = NullValueHandling.Ignore, ContractResolver = new JsonDCSPropertiesResolver(), }) + "\n"; var byteData = Encoding.UTF8.GetBytes(message); //Logger.Info("Sending Update over UDP 7080 DCS - 7082 Flight Panels: \n"+message); _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _globalSettings.GetNetworkSetting(GlobalSettingsKeys.OutgoingDCSUDPInfo))); //send to DCS _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _globalSettings.GetNetworkSetting(GlobalSettingsKeys .OutgoingDCSUDPOther))); // send to Flight Control Panels } catch (Exception e) { Logger.Error(e, "Exception Sending DCS Radio Update Message"); } }
//send updated radio info back to DCS for ingame GUI private void SendRadioUpdateToDCS() { if (_dcsRadioUpdateSender == null) { _dcsRadioUpdateSender = new UdpClient { ExclusiveAddressUse = false, EnableBroadcast = true }; _dcsRadioUpdateSender.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); _dcsRadioUpdateSender.ExclusiveAddressUse = false; } try { var connectedClientsSingleton = ConnectedClientsSingleton.Instance; int[] tunedClients = new int[11]; if (_clientStateSingleton.IsConnected && _clientStateSingleton.DcsPlayerRadioInfo != null && _clientStateSingleton.DcsPlayerRadioInfo.IsCurrent()) { for (int i = 0; i < tunedClients.Length; i++) { var clientRadio = _clientStateSingleton.DcsPlayerRadioInfo.radios[i]; if (clientRadio.modulation == RadioInformation.Modulation.FM || clientRadio.modulation == RadioInformation.Modulation.AM) { tunedClients[i] = connectedClientsSingleton.ClientsOnFreq(clientRadio.freq, clientRadio.modulation); } } } //get currently transmitting or receiving var combinedState = new CombinedRadioState() { RadioInfo = _clientStateSingleton.DcsPlayerRadioInfo, RadioSendingState = UdpVoiceHandler.RadioSendingState, RadioReceivingState = UdpVoiceHandler.RadioReceivingState, ClientCountConnected = _clients.Total, ClientCountIngame = _clients.InGame, TunedClients = tunedClients, }; var message = JsonConvert.SerializeObject(combinedState, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) + "\n"; var byteData = Encoding.UTF8.GetBytes(message); //Logger.Info("Sending Update over UDP 7080 DCS - 7082 Flight Panels: \n"+message); _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _globalSettings.GetNetworkSetting(GlobalSettingsKeys.OutgoingDCSUDPInfo))); //send to DCS _dcsRadioUpdateSender.Send(byteData, byteData.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), _globalSettings.GetNetworkSetting(GlobalSettingsKeys .OutgoingDCSUDPOther))); // send to Flight Control Panels } catch (Exception e) { Logger.Error(e, "Exception Sending DCS Radio Update Message"); } }