private void connectButton_Click(object sender, EventArgs e) { string user = UsernameTextBox.Text.Trim(); string pass = PasswordTextBox.Text.Trim(); string profile = ProfileTextBox.Text.Trim(); ConnectionLabel.Text = "Connecting..."; device = new EPOCEmotivDevice(user, pass, profile); bool connected = true; string error = ""; device.OnConnectAttempted += (c, em) => { connected = c; error = em; }; device.Connect(); if (connected) { ConnectionLabel.Text = "Device connected"; } else { MessageBox.Show("Unable to connect device: " + error, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); device = null; ConnectionLabel.Text = "Failed to connect device. Try again"; } }
protected override IEmotivDevice CreateDevice() { if (DeviceInstance == null) { DeviceInstance = base.CreateDevice(); bool suc = false; DeviceInstance.OnConnectAttempted += (b, m) => { suc = b; }; DeviceInstance.Connect(); if (suc == false) { throw new NullEmotivDeviceException(); } } return(DeviceInstance); }
/// <summary> /// Creates device either to random or Epoc device and insures connectivity. /// Call 'OnSuccess' when connection suceesd. /// </summary> public void Connect() { try { if (IsRandom) { Device = new RandomEmotivDevice(); } else { Device = new EPOCEmotivDevice(Username.text, Password.text, Profile.text); } string error = ""; bool suc = true; Device.OnConnectAttempted += (b, m) => { error = m; suc = b; }; Device.Connect(); if (suc) { title.text = "Connected!"; OnSucuess.Invoke(); } else { title.text = error; } } catch (Exception e) { title.text = e.ToString(); Crashlytics.RecordCustomException("Device Connection Exception", "thrown exception", e.StackTrace); } }
public override void Connect() { Content.Connect(); }