예제 #1
0
        public wb()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;

            // Start The Policy Server
            PolicySocketServer StartPolicyServer = new PolicySocketServer();
            Thread             th = new Thread(new ThreadStart(StartPolicyServer.StartSocketServer));

            th.IsBackground = true;
            th.Start();

            //initialize other servers
            ts  = new TextServer(this);
            ds  = new ImageServer(4531, this);
            ads = new AudioServer(this);
            //attach methods to delegates
            multicast_msg_2room = new msg2room(msg_to_room);
            sendroomlistdelobj  = new sendroomunamelistdelage(sendclientlist);
            setstreamimgob      = new setstreamimg(setimage);


            Status_lb.Items.Add("Ready...");
            //initialize database
            try
            {
                var result = from p in db.ServerSettings select p;
                if (result.Count() == 0)
                {
                    Status_lb.Items.Add("Initializing Server Settings in Database.");
                    ServerSetting ss = new ServerSetting();
                    ss.TextServerIP      = "0.0.0.0";
                    ss.TextServerPort    = 4530;
                    ss.AudioServerIP     = "0.0.0.0";
                    ss.ImageServerPort   = 4531;
                    ss.ImageServerIP     = "0.0.0.0";
                    ss.AudioServerPort   = 4532;
                    ss.TextServerOnline  = false;
                    ss.ImageServerOnline = false;
                    ss.AudioServerOnline = false;
                    ss.AutoConfig        = true;
                    db.ServerSettings.InsertOnSubmit(ss);
                    db.SubmitChanges();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        private void Start_btn_Click(object sender, EventArgs e)
        {
            if (TextServerchk.Checked == true)
            {
                if (textBox2.Text == "")
                {
                    ts = new TextServer(this);
                    Status_lb.Items.Add(ts.Start());
                    TextServerchk.Enabled = false;
                    textBox1.Text         = GetPublicIP();
                    Start_btn.Enabled     = false;
                    Stop_btn.Enabled      = true;
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.TextServerIP     = textBox1.Text;
                        result.TextServerPort   = 4530;
                        result.TextServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                if (checkifint(textBox2))
                {
                    ts = new TextServer(this, port);
                    Status_lb.Items.Add(ts.Start());
                    TextServerchk.Enabled = false;
                    textBox1.Text         = GetPublicIP();
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.TextServerIP     = textBox1.Text;
                        result.TextServerPort   = port;
                        result.TextServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                    Start_btn.Enabled = false;
                    Stop_btn.Enabled  = true;
                }
            }
            if (ImageServerchk.Checked == true)
            {
                if (textBox3.Text == "")
                {
                    ds = new ImageServer();
                    Status_lb.Items.Add(ds.Start());
                    ImageServerchk.Enabled = false;
                    textBox4.Text          = GetPublicIP();
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.ImageServerIP     = textBox4.Text;
                        result.ImageServerPort   = 4531;
                        result.ImageServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                    Start_btn.Enabled = false;
                    Stop_btn.Enabled  = true;
                }
                else
                if (checkifint(textBox3))
                {
                    ds = new ImageServer(port, this);
                    Status_lb.Items.Add(ds.Start());
                    ImageServerchk.Enabled = false;
                    textBox4.Text          = GetPublicIP();
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.ImageServerIP     = textBox4.Text;
                        result.ImageServerPort   = port;
                        result.ImageServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                    Start_btn.Enabled = false;
                    Stop_btn.Enabled  = true;
                }
            }

            if (AudioServerchk.Checked == true)
            {
                if (textBox5.Text == "")
                {
                    ads = new AudioServer(this);
                    Status_lb.Items.Add(ads.Start());
                    AudioServerchk.Enabled = false;
                    textBox6.Text          = GetPublicIP();
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.AudioServerIP     = textBox6.Text;
                        result.AudioServerPort   = 4532;
                        result.AudioServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                    Start_btn.Enabled = false;
                    Stop_btn.Enabled  = true;
                }
                else
                if (checkifint(textBox5))
                {
                    ads = new AudioServer(this, port);
                    Status_lb.Items.Add(ads.Start());
                    AudioServerchk.Enabled = false;
                    textBox6.Text          = GetPublicIP();
                    try
                    {
                        var result = (from p in db.ServerSettings select p).Single();
                        result.AudioServerIP     = textBox6.Text;
                        result.AudioServerPort   = port;
                        result.AudioServerOnline = true;
                        db.SubmitChanges();
                    }
                    catch (Exception)
                    {
                    }
                    Start_btn.Enabled = false;
                    Stop_btn.Enabled  = true;
                }
            }
            bool allchecked = false;

            if (TextServerchk.Checked == false & ImageServerchk.Checked == false & AudioServerchk.Checked == false)
            {
                Status_lb.Items.Add("Please, Select a server first.");
                allchecked = true;
            }
            Status_lb.SelectedIndex = Status_lb.Items.Count - 1;
            if (!allchecked)
            {
                TextServerchk.Enabled  = false;
                ImageServerchk.Enabled = false;
                AudioServerchk.Enabled = false;
            }
        }