public ChatServerForm(bool monitor = false)
        {
            InitializeComponent();
            var serviceHost = new ServiceHost(chat);

            try
            {
                serviceHost.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                serviceHost.Abort();
            }
            //chat.Manager.CreateRoomInternal(new Room { Name = "Главная", IsBound = true});
            FormClosed += delegate
            {
                chat.Stop();
                serviceHost.Close();
            };
            if (monitor)
            {
                timer.Interval = 1000;
                timer.Tick    += OnTimerTick;
                timer.Start();
            }
        }
Exemple #2
0
        protected override void OnStop()
        {
            if (serviceHostChat == null)
            {
                return;
            }
            try
            {
                serviceHostChat.Close();
                serviceHostWebChat.Close();
                chat.Stop();
            }
            catch (Exception ex)
            {
                Logger.Error("OnStop: error in host closing", ex);
            }

            try
            {
                serviceHostStatus.Close();
            }
            catch (Exception ex)
            {
                Logger.Error("OnStop: error in module status host closing", ex);
            }
        }