コード例 #1
0
ファイル: Form1.cs プロジェクト: Xackery/gobeam
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         //Create a connection
         var channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
         var rClient = new RobotService.RobotServiceClient(channel);
         var client = new RobotServiceClient(rClient);
         Console.WriteLine("Loaded");
         client.StreamReport();
     }
     catch (Exception err)
     {
         MessageBox.Show("Failed to load:", err.Message);
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Xackery/gobeam
 public RobotServiceClient(RobotService.RobotServiceClient client)
 {
     this.client = client;
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Xackery/gobeam
        private void btnConnect_Click(object sender, EventArgs e)
        {
            
            if (config == null || config.keys == null || config.keys.Length < 1)
            {
                MessageBox.Show("First load a key config before connecting.", "No keys are mapped", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            
            bool hasJoystick = false;
            foreach (var key in config.keys)
            {
                if (key.Type == "Joystick")
                {
                    hasJoystick = true;
                    break;
                }
            }
            if (hasJoystick && btnTestJoystick.Text == "Detect Joystick")
            {
                MessageBox.Show("There are uninitialized joysticks. Press Detect Joystick before connecting.", "Joysticks uninitialized.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

           

            if (client != null && channel != null)
            {
                if (tmrProgressUpdate.Enabled)
                {
                    tmrProgressUpdate.Enabled = false;
                    ProgressUpdateMassSet(false, 0);
                }
                DisconnectRPC();
                return;
            }

            try
            {
                
                SetStatus("Connecting to " + txtAddr.Text + "...");
                //Create a connection
                channel = new Channel(txtAddr.Text, ChannelCredentials.Insecure);
                var rClient = new RobotService.RobotServiceClient(channel);
                client = new RobotServiceClient(rClient);
                client.StreamReport();
                btnConnect.Text = "Disconnect";
                SetStatus("Connected to " + txtAddr.Text + ".");
                btnTestgRPC.Enabled = true;
            }
            catch (Exception err)
            {
                DisconnectRPC();
                MessageBox.Show("Failed to connect to gRPC client:", err.Message);                
            }
        }