/// <summary> /// Initializes a new instance of the <see cref="ButtplugClient"/> class. /// </summary> /// <param name="aClientName">The name of the client (used by the server for UI and permissions).</param> /// <param name="aConnector">Connector for the client.</param> public ButtplugClient([NotNull] string aClientName, [NotNull] IButtplugClientConnector aConnector) { ButtplugUtils.ArgumentNotNull(aConnector, nameof(aConnector)); Name = aClientName; _connector = aConnector; _connector.Disconnected += (aObj, aEventArgs) => { ServerDisconnect?.Invoke(aObj, aEventArgs); }; _connector.InvalidMessageReceived += ConnectorErrorHandler; _bpLogManager = new ButtplugLogManager(); _connector.LogManager = _bpLogManager; _bpLogger = _bpLogManager.GetLogger(GetType()); _bpLogger.Info("Finished setting up ButtplugClient"); }
public ButtplugNoPingTestClient(IButtplugClientConnector aConnector) : base("TestClient", aConnector) { }
public SystemMessageSendingClient([NotNull] string aClientName, [NotNull] IButtplugClientConnector aConnector) : base(aClientName, aConnector) { }
private async void Connect_Click(object sender, System.Windows.RoutedEventArgs e) { Connect.IsEnabled = false; if (_client != null) { await _client.DisconnectAsync(); _client = null; Devices.Clear(); ButtplugConnType.IsEnabled = false; ButtplugConnType_SelectionChanged(this, null); Connect.Content = "Connect"; Connect.IsEnabled = true; return; } IButtplugClientConnector conn = null; switch (((ComboBoxItem)ButtplugConnType.SelectedValue).Content) { case "WebSocket": try { conn = new ButtplugWebsocketConnector(new Uri(ButtplugTarget.Text)); } catch (UriFormatException e1) { MessageBox.Show($"Uri Error: {e1.Message}", "B******g Error", MessageBoxButton.OK, MessageBoxImage.Error); Connect.IsEnabled = true; return; } ButtplugTarget.IsEnabled = false; ButtplugConnType.IsEditable = false; break; case "IPC": ButtplugTarget.IsEnabled = false; ButtplugConnType.IsEditable = false; conn = new ButtplugClientIPCConnector(ButtplugTarget.Text); break; case "Embedded": ButtplugTarget.Text = ""; ButtplugTarget.IsEnabled = false; ButtplugConnType.IsEditable = false; //conn = new ButtplugEmbeddedConnector(new ButtplugServer()); //break; return; default: MessageBox.Show("Invalid Connection type!", "B******g Error", MessageBoxButton.OK, MessageBoxImage.Error); Connect.IsEnabled = true; return; } try { _client = new ButtplugClient("NogasmChart", conn); _client.DeviceAdded += ClientOnDeviceAdded; _client.DeviceRemoved += ClientOnDeviceRemoved; _client.ServerDisconnect += ClientOnServerDisconnect; _client.ErrorReceived += ClientOnErrorReceived; await _client.ConnectAsync(); await _client.StartScanningAsync(); } catch (Exception e1) { MessageBox.Show($"Something went wrong: {e1.Message}", "B******g Error", MessageBoxButton.OK, MessageBoxImage.Error); try { await _client?.DisconnectAsync(); } catch (Exception) { } _client = null; ButtplugConnType.IsEnabled = false; ButtplugConnType_SelectionChanged(this, null); Connect.Content = "Connect"; } Connect.Content = "Disconnect"; Connect.IsEnabled = true; }