public bool Create_Swarm(string SrcIP, string SrcPort, string Username)
{
try
{
Thread t1 = null;
string cpu = "1";
mSocket.SetIP(SrcIP);
mSocket.SetPort(SrcPort);
mSocket.SetName(Username);
mSocket.SetCPU(cpu);
listenerThread = new Thread(new ThreadStart(mSocket.StartListening));
listenerThread.IsBackground = true;
listenerThread.Start();
t1 = new Thread(new ThreadStart(mSocket.StarHeartBeat));
t1.IsBackground = true;
t1.Start();
mSocket.InsertPeer(mSocket.GetIP(), mSocket.GetPort(), mSocket.GetName(), mSocket.GetCPU());
mSocket.SetMaster(mSocket.GetIP() + ":" + mSocket.GetPort());
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Failed to create swarm.");
return false;
}
}