Ejemplo n.º 1
0
        public Connection(Server server, Socket socket)
        {
            if (server == null)
                throw new ArgumentNullException("server");

            if (socket == null)
                throw new ArgumentNullException("socket");

            this._server = server;
            this.Socket = socket;
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(App_ThreadException);
            AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(domain_ProcessExit);
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            tickcount = new Stopwatch();
            tickcount.Start();

            Console.WriteLine("  $$ Starting LKE DevTool..  ", ConsoleColor.Cyan);
            long StartTime = tickcount.ElapsedMilliseconds;

                string banner = @"

             888~-_
             888   \   e88~~8e  Y88b    /
             888    | d888  88b  Y88b  /  ____
             888    | 8888__888   Y88b/
             888   /  Y888    ,    Y8/
             ~~~888~~~  88___/      Y    888
            888     e88~-_   e88~-_  888  d88~\
            888    d888   i d888   i 888 C888
            888    8888   | 8888   | 888  Y88b
            888    Y888   ' Y888   ' 888   888D
            888      88_-~    88_-~  888 \_88P

                ";

            Console.WriteLine(banner, ConsoleColor.White);

            Console.WriteLine("  $$ Starting Loggers..  ", ConsoleColor.Cyan);
            MainLogger = new Logger("main.txt");
            ExceptLogger = new Logger("exception.txt");

            Console.WriteLine("  $$ Starting socket listener..  ", ConsoleColor.Cyan);
            _server = new Server();
            var ServerThread = new Thread(_server.run);
            ServerThread.Name = "ServerThread";
            ServerThread.Start();

            Console.WriteLine("  $$ Starting GUI..  ", ConsoleColor.Cyan);
            GUI = new GUI();
            var thread = new Thread(GUI.GUIThread); thread.Name = "GUI"; thread.Start();

            long stoptime = tickcount.ElapsedMilliseconds - StartTime;
            Console.WriteLine("  $$ Took : " + stoptime + "ms", ConsoleColor.Cyan);
        }
Ejemplo n.º 3
0
        public void Disconnect()
        {
            //      Logger.Trace("Disconnect() | server: " + _server);
            try
            {
            }
            catch { }
            if (_server != null)
            {
                // Use temp assignment to preven recursion.
                Server tempServer = _server;
                _server = null;
                tempServer.Disconnect(this);
            }

            if (this.Socket != null)
            {
                try
                {
                    this.Socket.Shutdown(SocketShutdown.Both);
                    this.Socket.Close();
                }
                catch (Exception)
                {
                    // Ignore any exceptions that might occur during attempt to close the Socket.
                }
                finally
                {
                    try
                    {
                        this.Socket.Dispose();
                        this.Socket = null;
                    }
                    catch { }
                }
            }
        }