private bool StartMulticastSender()
{
var isUnix = Environment.OSVersion.ToString().Contains("Unix");
string shell;
if (isUnix)
{
string dist = null;
var distInfo = new ProcessStartInfo
{
UseShellExecute = false,
FileName = "uname",
RedirectStandardOutput = true,
RedirectStandardError = true
};
using (var process = Process.Start(distInfo))
if (process != null) dist = process.StandardOutput.ReadToEnd();
shell = dist != null && dist.ToLower().Contains("bsd") ? "/bin/csh" : "/bin/bash";
}
else
{
shell = "cmd.exe";
}
var processArguments = GenerateProcessArguments();
if (processArguments == null) return false;
var senderInfo = new ProcessStartInfo {FileName = shell, Arguments = processArguments};
var logPath = HttpContext.Current.Server.MapPath("~") + Path.DirectorySeparatorChar + "private" +
Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + "multicast.log";
var logText = (Environment.NewLine + DateTime.Now.ToString("MM-dd-yy hh:mm") +
" Starting Multicast Session " +
_group.Name +
" With The Following Command:" + Environment.NewLine + senderInfo.FileName +
senderInfo.Arguments
+ Environment.NewLine);
File.AppendAllText(logPath, logText);
Process sender;
try
{
sender = Process.Start(senderInfo);
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
File.AppendAllText(logPath,
"Could Not Start Session " + _group.Name + " Try Pasting The Command Into A Command Prompt");
return false;
}
Thread.Sleep(2000);
if (sender == null) return false;
if (sender.HasExited)
{
File.AppendAllText(logPath,
"Session " + _group.Name + " Started And Was Forced To Quit, Try Running The Command Manually");
return false;
}
if (_isOnDemand)
{
_multicastSession.Pid = sender.Id;
_multicastSession.Name = _group.Name;
ActiveMulticastSession.AddActiveMulticastSession(_multicastSession);
}
else
{
_multicastSession.Pid = sender.Id;
ActiveMulticastSession.UpdateActiveMulticastSession(_multicastSession);
}
return true;
}