/// <summary>
        /// This initlizes the listner TCP connection and the #root channel.
        /// </summary>
        public void Init()
        {
            InitCommands();

            connection               = new TCPHandler();
            connection.Port          = Port;
            connection.OnMsg        += OnMessage;
            connection.OnConnection += (m, s) => {
                if (s == ConnectionStatus.Succes)
                {
                    PrintLine(m + ": Connected");
                }
                else
                {
                    PrintLine(m + ": Disconnected");
                }
            };

            connection.CreateSocket(true);

            Room rootRoom = new Room("#root");

            rootRoom.MOTD = "Welcome to the server! All Users are atumatically put into this room. Leaving this room will remove you form the server. Type \"/help\" for more info.";

            Rooms[rootRoom.Name] = rootRoom;
        }
        public void Init()
        {
            new Thread(() => {
                InitCommands();

                connection = new TCPHandler(Address, Port);

                connection.OnConnection += OnConnectionState;
                connection.OnMsg        += OnMesseage;
                connection.OnBadThing   += () => {
                    System.Windows.MessageBox.Show("You have been Disconnected from the server.", "Connection Closed", MessageBoxButton.OK);

                    //You'll notice these calls throughout the code,
                    //when working with WPF, you are not allowed to update the UI directly from anything but
                    //the UI thread. This ensures that the actions we want to take, are taken in the context
                    //of the UI thread.
                    IsConnected = false;
                    try {
                        Dispatcher.Invoke(new Action(() => {
                            Close();
                        }));
                    } catch (Exception) {
                        //Since the window actually closes during this process, this will throw an exception (Cause it can't compleate)
                        //So we catch it and do nothing with it.
                    }
                };

                connection.CreateSocket(false);

                new Thread(() => {
                    while (!IsConnected)
                    {
                        Thread.Sleep(500);
                    }

                    connection.Send("connect " + ourNickname);
                    ping.Enabled = true;

                    ping.Start();
                    //connection.Send("join nick #root");
                }).Start();
            }).Start();
        }
        /// <summary>
        /// This initlizes the listner TCP connection and the #root channel.
        /// </summary>
        public void Init()
        {
            InitCommands();

            connection = new TCPHandler();
            connection.Port = Port;
            connection.OnMsg += OnMessage;
            connection.OnConnection += (m, s) => {
                if (s == ConnectionStatus.Succes)
                    PrintLine(m + ": Connected");
                else
                    PrintLine(m + ": Disconnected");
            };

            connection.CreateSocket(true);

            Room rootRoom = new Room("#root");
            rootRoom.MOTD = "Welcome to the server! All Users are atumatically put into this room. Leaving this room will remove you form the server. Type \"/help\" for more info.";

            Rooms[rootRoom.Name] = rootRoom;
        }
        public void Init()
        {
            new Thread(() => {
                InitCommands();

                connection = new TCPHandler(Address, Port);

                connection.OnConnection += OnConnectionState;
                connection.OnMsg += OnMesseage;
                connection.OnBadThing += () => {
                    System.Windows.MessageBox.Show("You have been Disconnected from the server.", "Connection Closed", MessageBoxButton.OK);

                    //You'll notice these calls throughout the code,
                    //when working with WPF, you are not allowed to update the UI directly from anything but
                    //the UI thread. This ensures that the actions we want to take, are taken in the context
                    //of the UI thread.
                    IsConnected = false;
                    try {
                        Dispatcher.Invoke(new Action(() => {
                            Close();
                        }));
                    } catch (Exception) {
                        //Since the window actually closes during this process, this will throw an exception (Cause it can't compleate)
                        //So we catch it and do nothing with it.
                    }
                };

                connection.CreateSocket(false);

                new Thread(() => {
                    while (!IsConnected) {
                        Thread.Sleep(500);
                    }

                    connection.Send("connect " + ourNickname);
                    ping.Enabled = true;

                    ping.Start();
                    //connection.Send("join nick #root");
                }).Start();
            }).Start();
        }