Esempio n. 1
0
        public void SwitchToP2P(NetworkStream netStream, string key, Messagehandler mh)
        {
            if (window.InvokeRequired)
            {
                window.Invoke(new Action <NetworkStream, string, Messagehandler>(SwitchToP2P), new object[] { netStream, key, mh });
                return;
            }
            isP2P = true;
            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();
            window.attachmentPanel.Visible = true;
            window.userStatusLabel.Text    = "Online";
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void SwitchFromP2P(CustomStreamWriter streamWriter)
        {
            if (window.InvokeRequired)
            {
                window.Invoke(new Action <CustomStreamWriter>(SwitchFromP2P), new object[] { streamWriter });
                return;
            }
            window.attachmentPanel.Visible = false;
            window.userStatusLabel.Text    = "Offline";

            isP2P       = false;
            writer      = streamWriter;
            p2pListener = null;
        }
Esempio n. 4
0
    void Update()
    {
        if (initialized && !GameStarted())
        {
            float currentTime = Time.time;
            if (currentTime - P2PConnectionManager.connectionRequestSentTime > connectionRequestTimeoutTimeS)
            {
                Debug.Log("Connection request timeout");
                myLane = -1;
                DisplayError("Connection request timeout");
            }
        }

        if (initialized)
        {
            SendPositionInformation();
            P2PConsentManager.CheckForTimeoutPendingConsents();
            P2PListener.Listen();
        }
    }