} // SpeakIt private string BuildMumbleURI(RumbleConfigLine ConfigLine) { string MumbleURI = string.Empty; try { // logging MethodBase myMethod = new StackTrace().GetFrame(0).GetMethod(); MethodBeginLogging(myMethod); string portToUse = ConfigLine.Port; // no port specified, use default if (string.IsNullOrEmpty(portToUse)) { portToUse = "64738"; } // if string channelPath; if (ConfigLine.ChannelPath.Substring(0, 1) == @"/") { channelPath = ConfigLine.ChannelPath; } // if else { channelPath = @"/" + ConfigLine.ChannelPath; } // else if (string.IsNullOrEmpty(ConfigLine.Password)) { // mumble://[email protected]:23840/Open%20Talk/Subchannel%20A/?version=1.2.0 MumbleURI = string.Format("mumble://{0}@{1}:{2}{3}", ConfigLine.UserName, ConfigLine.ServerURL, portToUse, channelPath); } // if else { MumbleURI = string.Format("mumble://{0}:{1}@{2}:{3}{4}", ConfigLine.UserName, ConfigLine.Password, ConfigLine.ServerURL, portToUse, channelPath); } // else // logging MethodEndLogging(myMethod); } // try catch (Exception ex) { UtilityMethods.ExceptionHandler(ex, TraceString); } // catch return(MumbleURI); } // BuildMumbleURI
} // ResetDTMFCommandState private void LoadConfig(string ConfigNumber) { try { // logging MethodBase myMethod = new StackTrace().GetFrame(0).GetMethod(); MethodBeginLogging(myMethod); SetText(string.Format("Loading config {0}", ConfigNumber)); // clear out old config MyConfigs = new List <RumbleConfigLine>(); string configFileName = string.Format(@"\rumbleConfig_{0}.csv", ConfigNumber); string filePath = string.Format("{0}{1}", ConfigFilePath, configFileName); StreamReader sr = new StreamReader(filePath); string line; string[] dataRow = new string[6]; RumbleConfigLine thisRumbleConfigLine; while ((line = sr.ReadLine()) != null) { dataRow = line.Split(','); thisRumbleConfigLine = new RumbleConfigLine(); thisRumbleConfigLine.ServerNumber = dataRow[0]; thisRumbleConfigLine.ChannelNumber = dataRow[1]; thisRumbleConfigLine.ServerURL = dataRow[2]; thisRumbleConfigLine.Port = dataRow[3]; thisRumbleConfigLine.UserName = dataRow[4]; thisRumbleConfigLine.Password = dataRow[5]; thisRumbleConfigLine.ChannelPath = dataRow[6]; thisRumbleConfigLine.ServerNickname = dataRow[7]; thisRumbleConfigLine.ChannelNickname = dataRow[8]; MyConfigs.Add(thisRumbleConfigLine); } // while SpeakIt(string.Format("Configuration file number {0} has been loaded.", ConfigNumber)); // logging MethodEndLogging(myMethod); } // try catch (Exception ex) { UtilityMethods.ExceptionHandler(ex, TraceString); } // catch } // LoadConfig
} // ProcessDTMFCommand private void ChangeChannel(string ServerNumber, string ChannelNumber) { try { // logging MethodBase myMethod = new StackTrace().GetFrame(0).GetMethod(); MethodBeginLogging(myMethod); SetText(string.Format("changing channel to server {0}, channel {1}", ServerNumber, ChannelNumber)); if (ChannelNumber == "0") { LaunchMumble(ResetURI); Thread.Sleep(500); } // if RumbleConfigLine matchingConfig = new RumbleConfigLine(); // find matching config line foreach (RumbleConfigLine myLine in MyConfigs) { if (myLine.ServerNumber == ServerNumber) { if (myLine.ChannelNumber == ChannelNumber) { matchingConfig = myLine; break; } // if } // if } // foreach // get URI from config based on server and channel number if (!string.IsNullOrEmpty(matchingConfig.ServerURL)) { string mumbleURI = BuildMumbleURI(matchingConfig); LaunchMumble(mumbleURI); string serverName = string.Empty; string channelName = string.Empty; if (!string.IsNullOrEmpty(matchingConfig.ServerNickname)) { serverName = matchingConfig.ServerNickname; } // if else { serverName = string.Format("server {0}", ServerNumber); } // else if (!string.IsNullOrEmpty(matchingConfig.ChannelNickname)) { channelName = matchingConfig.ChannelNickname; } // if else { channelName = string.Format("channel {0}", ChannelNumber); } // else SpeakIt(string.Format("Channel changed to {0}, {1}.", serverName, channelName)); } // if else { SpeakIt("requested server and channel pair could not be found in the current config."); } // else // logging MethodEndLogging(myMethod); } // try catch (Exception ex) { UtilityMethods.ExceptionHandler(ex, TraceString); } // catch } // Change channel