private void LaunchClientBroker(FTPClientBroker broker) { ThreadStart ths = new ThreadStart(broker.Start); Thread thd = new Thread(ths); thd.Start(); GlobalRuntime.Threads.Add(thd); }
public static FTPClientBroker GetOrCreateClientBrokerByDataClient(TcpClient dataClient) { string remoteIp = Convert2IP(dataClient.Client.RemoteEndPoint.ToString()); if (!Brokers.ContainsKey(remoteIp)) { FTPClientBroker broker = new FTPClientBroker(); broker.DataTcpClient = dataClient; Brokers[remoteIp] = broker; } Brokers[remoteIp].DataTcpClient = dataClient; return(Brokers[remoteIp]); }
public void ProcessDataClientArrival(IAsyncResult iar) { TcpListener listener = (TcpListener)iar.AsyncState; TcpClient client = listener.EndAcceptTcpClient(iar); Monitor.Enter(this); FTPClientBroker broker = FTPClientBrokerFactory.GetOrCreateClientBrokerByDataClient(client); if (IsLaunchable(broker)) { broker.NewTextMessageArrival += broker_NewTextMessageArrival; broker.FileTransferNotify += broker_FileTransferNotify; LaunchClientBroker(broker); } Monitor.Exit(this); if (this.NewDataClientConnected != null) { this.NewDataClientConnected.Invoke(client.Client.RemoteEndPoint.ToString()); } }
private bool IsLaunchable(FTPClientBroker broker) { return(broker.CommandTcpClient != null && broker.DataTcpClient != null); }