示例#1
0
 private void _onConnected(object sender, EventArgs e)
 {
     newCmd("PSW,SET," + connectionParams.password);
     newCmd("EVT,ON");
     pingTimer = new System.Threading.Timer(obj => newCmd(""), null, timeout, timeout);
     if (usartConnection != null)
     {
         usartConnection.connect(connectionParams.host, connectionParams.usartPort, true);
     }
     onConnected?.Invoke(this, e);
 }
示例#2
0
        private void login()
        {
            using (FLogin lf = new FLogin(Application.StartupPath + "\\clusters.txt"))
            {
                lf.tbCallsign.Text = settings.cs;
                lf.tbHost.Text     = settings.host;
                if (settings.port != 0)
                {
                    lf.tbPort.Text = settings.port.ToString();
                }
                if (lf.ShowDialog() == DialogResult.OK)
                {
                    string host     = lf.tbHost.Text;
                    int    port     = Convert.ToInt32(lf.tbPort.Text);
                    string callsign = lf.tbCallsign.Text;
                    if (!callsign.Equals(settings.cs))
                    {
                        settings.cs = callsign;
                    }
                    if (!host.Equals(settings.host))
                    {
                        settings.host = host;
                    }
                    if (port != settings.port)
                    {
                        settings.port = port;
                    }
                    writeConfig();

                    if (host == "test")
                    {
                        using (StreamReader sr = new StreamReader(Application.StartupPath + "\\test.txt"))
                            do
                            {
                                LineReceivedEventArgs e = new LineReceivedEventArgs();
                                e.line = sr.ReadLine();
                                lineReceived(this, e);
                            } while (sr.Peek() >= 0);
                    }
                    else
                    {
                        clusterCn = new AsyncConnection();
                        clusterCn.lineReceived += lineReceived;
                        if (clusterCn.connect(host, port))
                        {
                            clusterCn.sendCommand(callsign);
                            this.Text += " connected to " + host + ":" + port.ToString();
                        }
                    }
                }
            }
        }
示例#3
0
 public bool connect()
 {
     connection = new AsyncConnection();
     connection.connect(connectionParams.host, connectionParams.port);
     if (connection.connected)
     {
         connection.lineReceived += processReply;
         if (connectionParams.usartPort != -1)
         {
             sendCommand("PSW,SET," + connectionParams.password);
             sendCommand("EVT,ON");
             usartConnection = new AsyncConnection();
             usartConnection.connect(connectionParams.host, connectionParams.usartPort);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#4
0
 public void listenWirelessGW()
 {
     sport?.Close();
     listenWirelessGWFl = true;
     if (wirelessGWCheckTimer == null)
     {
         wirelessGWCheckTimer = new System.Threading.Timer(obj => {
             if (listenWirelessGWFl)
             {
                 listenWirelessGW();
             }
         }, null, 10000, 10000);
     }
     foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
     {
         if (ni.NetworkInterfaceType.ToString().StartsWith("Wireless"))
         {
             GatewayIPAddressInformationCollection gws = ni.GetIPProperties().GatewayAddresses;
             if (gws?.Count > 0 && ni.OperationalStatus == OperationalStatus.Up)
             {
                 if (gpsShare == null)
                 {
                     gpsShare = new AsyncConnection();
                     gpsShare.connect(ni.GetIPProperties().GatewayAddresses[0].Address.ToString(), 50000, true);
                     gpsShare.reconnect       = true;
                     gpsShare.lineReceived   += GpsShare_lineReceived;
                     gpsShare.onDisconnected += GpsShare_onDisconnected;
                     gpsShare.onConnected    += GpsShare_onConnected;
                 }
             }
             else if (gpsShare != null)
             {
                 gpsShare.disconnect();
                 gpsShare = null;
             }
         }
     }
 }
示例#5
0
 public bool connect()
 {
     _active = true;
     connection.connect(connectionParams.host, connectionParams.port);
     return(connected);
 }
示例#6
0
 public bool connect()
 {
     return(ac.connect(_host, _port));
 }