예제 #1
0
 private void UpdateServiceList(NavicoJson.UnitServiceInfo info)
 {
     this.Invoke((MethodInvoker) delegate()
     {
         cb_IP.Items.Add(info);
         if (cb_IP.Items.Count == 1)
         {
             cb_IP.SelectedItem = info;
         }
     }
                 );
 }
예제 #2
0
 /// <summary>
 /// Connect button event handler. Try to connect to the websocket server
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Connect_Click(object sender, EventArgs e)
 {
     if (m_MessageHandler.SocketState != WebSocketState.Open)
     {
         System.Net.IPAddress       address;
         NavicoJson.UnitServiceInfo info = cb_IP.SelectedItem as NavicoJson.UnitServiceInfo;
         if (info != null) // if we're using a properly populated entry
         {
             if (System.Net.IPAddress.TryParse(info.IP, out address))
             {
                 String url = "ws://" + address.ToString() + ":" + info.WebsocketPort;
                 m_MessageHandler.Init(url);
             }
         }
         else // has the user typed an IP address?
         {
             if (System.Net.IPAddress.TryParse(cb_IP.Text, out address))
             {
                 String url = "ws://" + address.ToString() + ":" + 2053;
                 m_MessageHandler.Init(url);
             }
         }
     }
 }