예제 #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TCPConnectionProperties tcpconnprop = ConfigurationManager.TCPConnectionHistory[comboBox1.SelectedIndex];

            textBox1.Text        = tcpconnprop.Alias;
            numericUpDown1.Value = tcpconnprop.Port;
        }
        public static async Task <ManagedStreamV2> GenerateInstance(ulong device_id)
        {
            ManagedStreamV2 stream_gen = null;

            var sqlconn = await ARDBConnectionManager.default_manager.CheckOut();

            try
            {
                TCPConnectionProperties tcpconnprop = await DatabaseUtilities.GetDevicePropertiesFromDatabase(sqlconn.Connection, device_id);

                stream_gen = new ManagedStreamV2(device_id, tcpconnprop.AddressString, tcpconnprop.Port);

                await stream_gen.InitConnection();
            }
            catch (Exception ex) { }

            ARDBConnectionManager.default_manager.CheckIn(sqlconn);

            return(stream_gen);
        }
예제 #3
0
        private async void button1_Click(object sender, EventArgs e)
        {
            //okay button

            if (comboBox1.Text.Trim() != "")
            {
                comboBox1.Enabled      = false;
                numericUpDown1.Enabled = false;
                textBox1.Enabled       = false;

                UseWaitCursor = true;

                try
                {
                    Console.WriteLine((await Dns.GetHostAddressesAsync(comboBox1.Text))[0].ToString());

                    connprop = new TCPConnectionProperties(textBox1.Text, comboBox1.Text, Convert.ToInt32(numericUpDown1.Value));
                }
                catch (Exception ex)
                {
                    numericUpDown1.Enabled = true;
                    comboBox1.Enabled      = true;
                    textBox1.Enabled       = true;

                    UseWaitCursor = false;

                    comboBox1.Focus();

                    return;
                }

                ConfigurationManager.AddTCPConnectionHistoryItem(connprop);

                DialogResult = DialogResult.OK;
            }
        }
        private static async Task UDPAnnounce()
        {
            UdpClient udp_client = null;

            try
            {
                udp_client = new UdpClient();
                udp_client.EnableBroadcast = true;
            }
            catch (Exception ex)
            {
                if (udp_client != null)
                {
                    udp_client.Close();
                }

                DeviceServer.logger.AppendLog(DateTime.Now, "SA - An error occured while opening a broadcast client. Holding off for 1 minute.");
                await Task.Delay(60000);

                return;
            }

            string s;

            try
            {
                s = GetHostAddress();
            }
            catch (Exception ex) { return; }

            TCPConnectionProperties tcpconnprop = new TCPConnectionProperties("Device Server", s, sync_broadcast_port);

            HostInfo hi = new HostInfo();

            hi.HostGUID = host_guid;
            hi.TCPConnectionProperties = tcpconnprop;

            byte[] b;
            using (MemoryStream ms = new MemoryStream())
            {
                try
                {
                    xmlSerializer.WriteObject(ms, hi);
                }
                catch (Exception ex)
                {
                    DeviceServer.logger.AppendLog(DateTime.Now, "SA - Ann error occured during HostInfo serialization.");
                    return;
                }

                ms.Flush();
                b = ms.ToArray();
            }

            try
            {
                IPEndPoint local_endpoint = new IPEndPoint(IPAddress.Broadcast.Address, sync_broadcast_port);
                udp_client.Send(b, b.Length, local_endpoint);
            }
            catch (Exception ex)
            {
                if (udp_client != null)
                {
                    udp_client.Close();
                }

                DeviceServer.logger.AppendLog(DateTime.Now, "SA - An error occured while sending the HostInfo message. Holding off for 1 minute.");
                await Task.Delay(60000);
            }

            if (udp_client != null)
            {
                udp_client.Close();
            }
        }
예제 #5
0
 public TCPConnectionHistoryMenuItem(TCPConnectionProperties tcpconnprop)
 {
     this.tcpconnprop = tcpconnprop;
     this.Text        = tcpconnprop.ToString();
 }