public static bool ListenToAny() { // start listening to connecting clients for a ListenSeconds time var watch = Stopwatch.StartNew(); //Logger.Status("Waiting for clients ..."); var listener = new TcpListener(IPAddress.Any, Port); listener.Start(); while (watch.ElapsedMilliseconds < ListenSeconds * 1000) { while (listener.Pending()) { IdaClient client = new IdaClient(listener.AcceptTcpClient()); RegisterClient(client); listener.Stop(); listener = new TcpListener(IPAddress.Any, Port); listener.Start(); } Thread.Sleep(RetrySeconds * 1000); } listener.Stop(); if (ClientList.Count == 0) { Logger.Status("failed to connect to clients"); return(false); } Logger.Status(string.Format("Successfully connected to {0} clients", ClientList.Count)); return(true); }
public static void RegisterClient(IdaClient client) { client.IsRegistered = true; ClientList.Add(client); client.TheStream = client.GetStream(); client.RecieveMessage(); HandleClientMessage(client); }
private static void HandleClientMessage(IdaClient client) { switch (client.TheMessage.Action) { case Message.ActionType.JobAbort: //client.JobList. break; case Message.ActionType.JobRequest: break; case Message.ActionType.Register: var list = client.TheMessage.Text.Split(' ').ToList(); client.Ip = IPAddress.Parse(list[0]); client.Name = list[1]; client.NumCores = Convert.ToInt16(list[2]); Logger.UpdateForClients(); break; case Message.ActionType.ResultSet: break; } }
public void SetClientTableEntry(IdaClient client) { if (ClientsTable.InvokeRequired == false) { var rowList = ClientsTable.Rows.Cast <DataGridViewRow>().Where( ro => (string)ro.Cells["IP"].Value == client.Ip.ToString()).ToList(); DataGridViewRow row; if (rowList.Count > 0) { row = rowList[0]; } else { row = new DataGridViewRow(); row.Cells["Name"].Value = client.Name; row.Cells["IP"].Value = client.Ip.ToString(); row.Cells["NumCores"].Value = client.NCores; ClientJobDic[client] = client.JobList; ClientActivityDic[client] = client.ActivityLogList; } row.Cells["Connection"].Value = client.Connected? "Online" : "Offline"; row.Cells["WorkingCores"].Value = client.NWorkingCores; } else { var dlgt = new SetIdaTableEntryDelegate(SetIdaTableEntry); try { Invoke(dlgt, client); } catch { Thread.Sleep(1000); Invoke(dlgt, client); } } }
public static void UnRegister(IdaClient client) { client.IsRegistered = false; }
private static void ShowClientJobs(IdaClient client) { MessageBox.Show("Client Jobs Table Will be Implemented Soon", "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
private static void ShowClientActivity(IdaClient client) { MessageBox.Show("Client Activity Graph Will be Implemented Soon", "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
public static void LogConnectioFailed(IdaClient data) { //Log("failed to connect to {data.Name} computer"); }
public static void LogNumCoresChanged(IdaClient idaClient) { //Log("Client {IdaClient.Name} is running with {IdaClient.NCores} cores"); }
internal static void LogJobSent(SingleRunJob job, IdaClient idaClient) { //Log(string.Format("New job (model= {0}, record= {1}, IM= {2}) was sent to {3} computer", job.Model, job.Record, job.Im, idaClient.Name)); }