private void Window1_Loaded(object sender, RoutedEventArgs e) { // Create new instance of classes and delegates UpdateInfoTxt = new UpdateInfoTxtDelegate(UpdateInfoTxtMethod); // need to define the delegate before the class, it gets passed to the class server = new TcpServer(UpdateInfoTxt, Window1); client = new MyTCPClient(UpdateInfoTxt); listener = new UdpListener(UpdateInfoTxt); server.servIP = Dns.GetHostAddresses(Dns.GetHostName())[0]; client.ip = Dns.GetHostAddresses(Dns.GetHostName())[0]; this.ServIP_txt.Text = server.servIP.ToString(); server.servPort = Convert.ToInt32(this.servPort_txt.Text); client.port = Convert.ToInt32(this.servPort_txt.Text); this.statusBox_txt.Text = ""; this.filePath_txt.Text = Directory.GetCurrentDirectory() + @"\vgsslogs\" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss-tt") + ".txt"; }
public UdpListener(UpdateInfoTxtDelegate d) { UpdateInfoTxt = d; }
// Constructor public MyTCPClient(UpdateInfoTxtDelegate d) { UpdateInfoTxt = d; }
private TcpClient client; // this is the client that connected to our server // Constructor public TcpServer(UpdateInfoTxtDelegate d, Window w) { UpdateInfoTxt = d; win = w; }