示例#1
0
        private void FormController_Load(object sender, EventArgs e)
        {
            GetLoginInfo getLogin  = new GetLoginInfo();
            FormLogin    formLogin = new FormLogin(getLogin);

            formLogin.ShowDialog();
            if (getLogin.login == null || getLogin.login == "")
            {
                Application.Exit();
            }
            FormChat formChat = new FormChat(getLogin);

            formChat.ShowDialog();
            Application.Exit();
        }
示例#2
0
        public CircleConnection(FormChat formChat, DataController dataController, string username, string backComNumber, string forwardComNumber)
        {
            back                    = new SerialPort("COM" + backComNumber);
            back.Parity             = Parity.None;
            back.Handshake          = Handshake.RequestToSend;
            back.BaudRate           = 9600;
            back.ReadBufferSize     = 4 * 1024;
            forward                 = new SerialPort("COM" + forwardComNumber);
            forward.Parity          = Parity.None;
            forward.Handshake       = Handshake.RequestToSend;
            forward.BaudRate        = 9600;
            forward.WriteBufferSize = 4 * 1024;

            msgBuffer     = new List <byte>();
            framesToSend  = new List <List <byte> >();
            needStartByte = true;

            this.formChat       = formChat;
            this.lastFormTitle  = "";
            this.dataController = dataController;

            currentState      = FrameType.Voting;
            inputUserName     = username;
            currentUserName   = inputUserName;
            currentUserID     = -1;
            noConnectionTimer = 0;

            sendedMessages = new Dictionary <int, UserMessage>();

            maxMarkerUserName = username;

            currentMarkerWeight = new byte[16];

            byte[] weight_1 = new byte[8];
            (new Random()).NextBytes(weight_1);
            Buffer.BlockCopy(weight_1, 0, currentMarkerWeight, 0, weight_1.Length);
            byte[] weight_2 = new byte[8];
            (new Random(DateTime.Now.Second * 1000 + DateTime.Now.Millisecond)).NextBytes(weight_2);
            Buffer.BlockCopy(weight_2, 0, currentMarkerWeight, weight_1.Length, weight_2.Length);

            resendCount = 0;

            back.Open();
            forward.Open();

            SendClose();
        }