Ejemplo n.º 1
0
        public IndividualChatDriver(string username, string receiver, FileManager fm, NetworkStream netstream, Messagehandler mh, string key, string status)
        {
            isP2P                = true;
            this.username        = username;
            this.receiver        = receiver;
            this.fm              = fm;
            window               = new IndividualChatWindow(receiver);
            window.WindowState   = FormWindowState.Minimized;
            window.ShowInTaskbar = false;
            window.getStatusTextLabel().Text = status;
            spam = new SpamProtector();
            SetupListners();

            int NumberChars = key.Length;

            byte[] personalKey = new byte[NumberChars / 2];
            for (int i = 0; i < NumberChars; i += 2)
            {
                personalKey[i / 2] = System.Convert.ToByte(key.Substring(i, 2), 16);
            }

            writer      = new P2PWriter(netstream, personalKey);
            p2pListener = new P2PListener(netstream, receiver, personalKey);
            writer      = new P2PWriter(netstream, personalKey);

            mh.Subscribe(p2pListener);
            p2pListener.StartListen();

            new Thread(() => Application.Run(window)).Start();
            Thread.Sleep(10);
        }
Ejemplo n.º 2
0
 public IndividualChatDriver(CustomStreamWriter sllWriter, string Username, string Receiver, FileManager fm, string status)
 {
     isP2P      = false;
     username   = Username;
     receiver   = Receiver;
     fileToSend = null;
     this.fm    = fm;
     window     = new IndividualChatWindow(receiver);
     window.getStatusTextLabel().Text = status;
     spam = new SpamProtector();
     SetupListners();
     writer               = sllWriter;
     window.WindowState   = FormWindowState.Minimized;
     window.ShowInTaskbar = false;
     new Thread(() => Application.Run(window)).Start();
     Thread.Sleep(10);
     //new Thread(() => window.Show()).Start();
 }