public MainWindow(string Host, string Name)
        {
            InitializeComponent();

            TCP           = new MyEasyTCP(Constants.BufferSize);
            TCP.OnData   += TCP_OnData;
            TCP.OnClosed += TCP_OnClosed;

            TCP.Connect(new TcpClient(Host, PORT), 1, 0);

            TCP.Send(0, Name);

            Title = Name;

            Closed += (s, e) => TCP.SendCloseRequest();
        }
Beispiel #2
0
        private void ListenerTimer_Tick(object sender, EventArgs e)
        {
            if (Listener.Pending())
            {
                try
                {
                    var MyStream = new MyEasyTCP(Constants.BufferSize);
                    MyStream.OnData   += MyStream_OnInfo;
                    MyStream.OnClosed += MyStream_OnClosed;

                    MyStream.Connect(Listener.AcceptTcpClient(), 1, 0);
                }
                catch (Exception E)
                {
                    var R = new Run
                    {
                        Foreground = Brushes.Red,
                        Text       = "Error: " + E.Message + Environment.NewLine
                    };
                    TB.Inlines.Add(R);
                }
            }
        }