Пример #1
0
        private void EndConnection()
        {
            stop = true;
            if (messager == null)
            {
                return;
            }
            Logout l = new Logout();

            messager.AddMessages(l);
            messager.SendMessages(client);
            //There are better ways to stop this thread.  Ok for now.
            alive.Interrupt();
            client.Close();
        }
Пример #2
0
        public void Start(Object o)
        {
            connectionClosed += EndConnection;
            WindowMngr        = o as KailleraNET.KailleraWindowController;
            if (initConnection())
            {
                //Send Logon
                messager = new UDPMessenger(ip);
                messager.AddMessages(new UserLogonInstruction(username + "\0", 1));
                messager.SendMessages(client);
                //Begin recieving and processing loop
                alive = new Thread(KeepAlive);
                //alive.Start(ip);

                /*     System.Timers.Timer KeepAliveTimer = new System.Timers.Timer();
                 *   KeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(KeepAliveSameThread);
                 *   KeepAliveTimer.Interval = 60000;
                 *   KeepAliveTimer.AutoReset = true;
                 *   KeepAliveTimer.Enabled = true;
                 */
                alive.Start(ip);
                Recieve();
            }
            else //If we didn't connect successfully, return to the main window
            {
                KailleraWindowController.getMgr().connectionFailed();
            }
        }
Пример #3
0
        public void Start(Object o)
        {
            connectionClosed += EndConnection;
            WindowMngr = o as KailleraNET.KailleraWindowController;
            if (initConnection())
            {
                //Send Logon
                messager = new UDPMessenger(ip);
                messager.AddMessages(new UserLogonInstruction(username + "\0", 1));
                messager.SendMessages(client);
                //Begin recieving and processing loop
                alive = new Thread(KeepAlive);
                //alive.Start(ip);
                /*     System.Timers.Timer KeepAliveTimer = new System.Timers.Timer();
                     KeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(KeepAliveSameThread);
                     KeepAliveTimer.Interval = 60000;
                     KeepAliveTimer.AutoReset = true;
                     KeepAliveTimer.Enabled = true;
                 */
                alive.Start(ip);
                Recieve();
            }
            else //If we didn't connect successfully, return to the main window
            {
                KailleraWindowController.getMgr().connectionFailed();
            }

            
        }