Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            if (Application.Current == null)
            {
                return;
            }

            ButtplugTab.SetServerDetails("Kiiroo Emulator", 0);
            _bpServer = ButtplugTab.GetServer();
            _bpServer.SendMessage(new RequestServerInfo("Kiiroo Emulator")).Wait();
            InitializeComponent();
            _kiirooEmulator = new KiirooPlatformEmulator();
            _kiirooEmulator.OnKiirooPlatformEvent += HandleKiirooPlatformMessage;
            _kiirooEmulator.OnException           += HandleKiirooPlatformMessage;
            _translator = new KiirooMessageTranslator();
            _translator.VibrateEvent += OnVibrateEvent;
            _ops = new List <DispatcherOperation>();
            var emu = new KiirooEmulatorPanel();

            ButtplugTab.AddDevicePanel(_bpServer);
            ButtplugTab.SetApplicationTab("Kiiroo Emulator", emu);
            Closing += ClosingHandler;
            StartServer();
            emu.ServerStatusChanged            += OnServerStatusChanged;
            ButtplugTab.SelectedDevicesChanged += SelectionChangedHandler;

            var config = new ButtplugConfig("B******g");

            ButtplugTab.GetAboutControl().CheckUpdate(config, "b******g-csharp");
        }
Beispiel #2
0
        public async void RequestServerInfoTest()
        {
            var s       = new ButtplugServer("TestClient", 100);
            var results = new List <ButtplugMessage> {
                await s.SendMessage(new RequestServerInfo("TestClient"))
            };

            results.AddRange(await s.SendMessage("[{\"RequestServerInfo\":{\"Id\":1, \"ClientName\":\"TestClient\"}}]"));

            foreach (var reply in results)
            {
                ServerInfo r;

                try
                {
                    r = (ServerInfo)reply;
                }
                catch (InvalidCastException)
                {
                    Assert.True(reply is ServerInfo);
                    continue;
                }

                Assert.True(r.MajorVersion == Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Major);
                Assert.True(r.MinorVersion == Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Minor);
                Assert.True(r.BuildVersion == Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Build);
            }
        }
        private async void CheckDeviceCount(ButtplugServer aServer, int aExpectedCount)
        {
            var deviceListMsg = await aServer.SendMessage(new RequestDeviceList());

            Assert.True(deviceListMsg is DeviceList);
            Assert.Equal(((DeviceList)deviceListMsg).Devices.Length, aExpectedCount);
        }
        public void TestLicenseFileLoading()
        {
            var license = ButtplugServer.GetLicense();

            Assert.Contains("B******g is covered under the following BSD 3-Clause License", license);
            Assert.Contains("NJsonSchema (https://github.com/RSuter/NJsonSchema) is covered under the", license);
        }
        public MainWindow()
        {
            InitializeComponent();
            if (Application.Current == null)
            {
                return;
            }
            ButtplugTab.GetLogControl().MaxLogs = 10000;

            ButtplugTab.SetServerDetails("Game Vibration Router Server", 0);
            _bpServer = ButtplugTab.GetServer();
            _log      = LogManager.GetCurrentClassLogger();
            ButtplugGameVibrationRouterInterface.VibrationCommandReceived     += OnVibrationCommand;
            ButtplugGameVibrationRouterInterface.VibrationPingMessageReceived += OnVibrationPingMessage;
            ButtplugGameVibrationRouterInterface.VibrationExceptionReceived   += OnVibrationException;
            ButtplugGameVibrationRouterInterface.VibrationExitReceived        += OnVibrationExit;
            Task.FromResult(_bpServer.SendMessage(new RequestServerInfo("B******g Game Vibration Router")));
            _processTab = new ProcessTab();
            _processTab.ProcessAttachRequested += OnAttachRequested;
            _processTab.ProcessDetachRequested += OnDetachRequested;
            ButtplugTab.SetApplicationTab("Processes", _processTab);
            ButtplugTab.AddDevicePanel(_bpServer);
            ButtplugTab.SelectedDevicesChanged += OnSelectedDevicesChanged;

            var config = new ButtplugConfig("B******g");

            ButtplugTab.GetAboutControl().CheckUpdate(config, "b******g-csharp");
        }
        private async Task CheckDeviceCount(ButtplugServer aServer, int aExpectedCount)
        {
            var deviceListMsg = await aServer.SendMessageAsync(new RequestDeviceList());

            deviceListMsg.Should().BeOfType <DeviceList>();
            ((DeviceList)deviceListMsg).Devices.Length.Should().Be(aExpectedCount);
        }
        private void CheckDeviceCount(ButtplugServer aServer, int aExpectedCount)
        {
            var deviceListMsg = aServer.SendMessage(new RequestDeviceList()).GetAwaiter().GetResult();

            Assert.True(deviceListMsg is DeviceList);
            Assert.AreEqual(((DeviceList)deviceListMsg).Devices.Length, aExpectedCount);
        }
Beispiel #8
0
        public async void NonRequestServerInfoFirstTest()
        {
            var s = new ButtplugServer("TestClient", 100);

            Assert.True(await s.SendMessage(new Core.Messages.Test("Test")) is Error);
            Assert.True(await s.SendMessage(new RequestServerInfo("TestClient")) is ServerInfo);
            Assert.True(await s.SendMessage(new Core.Messages.Test("Test")) is Core.Messages.Test);
        }
Beispiel #9
0
        public override void SetUpConnector()
        {
            _subtypeMgr = new TestDeviceSubtypeManager(new TestDevice(_logMgr, "Test Device"));
            _server     = new TestServer();

            // This is a test, so just ignore the logger requirement for now.
            _server.AddDeviceSubtypeManager(aLog => _subtypeMgr);
            _connector = new ButtplugEmbeddedConnector(_server);
            _client    = new ButtplugClient("Test Client", _connector);
        }
Beispiel #10
0
        public async Task TestRequestServerInfo()
        {
            var s = new ButtplugServer("TestServer", 100);
            var r = await s.SendMessageAsync(new RequestServerInfo("TestClient"));

            r.Should().BeOfType <ServerInfo>();
            var info = r as ServerInfo;

            info.MajorVersion.Should().Be(Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Major);
            info.MinorVersion.Should().Be(Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Minor);
            info.BuildVersion.Should().Be(Assembly.GetAssembly(typeof(ServerInfo)).GetName().Version.Build);
        }
Beispiel #11
0
        public ButtplugWebsocketServerSession(IButtplugLogManager aLogManager, ButtplugServer aServer, WebSocket aSocket, CancellationTokenSource aExternalCancelSource)
        {
            _logger = aLogManager.GetLogger(GetType());
            _internalCancelSource = new CancellationTokenSource();

            _linkedCancelSource = CancellationTokenSource.CreateLinkedTokenSource(aExternalCancelSource.Token, _internalCancelSource.Token);
            _ws     = aSocket;
            _server = aServer;
            _server.MessageReceived += ReceiveMessageFromServerHandler;
            _server.ClientConnected += ClientConnectedHandler;
            _server.PingTimeout     += PingTimeoutHandler;
        }
Beispiel #12
0
        public async Task TestDoNotRequestServerInfoFirst()
        {
            var s = new ButtplugServer("TestServer", 0);

            s.Awaiting(async aServer => await s.SendMessageAsync(new Core.Messages.Test("Test"))).Should().Throw <ButtplugHandshakeException>();

            var msg = await s.SendMessageAsync(new RequestServerInfo("TestClient"));

            msg.Should().BeOfType <ServerInfo>();

            msg = await s.SendMessageAsync(new Core.Messages.Test("Test"));

            msg.Should().BeOfType <Core.Messages.Test>();
        }
Beispiel #13
0
        public MainWindow()
        {
            InitializeComponent();
            if (Application.Current == null)
            {
                return;
            }
            ButtplugTab.GetLogControl().MaxLogs = 10000;

            ButtplugTab.SetServerDetails("Game Vibration Router Server", 0);
            _bpServer = ButtplugTab.GetServer();
            _log      = LogManager.GetCurrentClassLogger();
            ButtplugGameVibrationRouterInterface.VibrationCommandReceived     += OnVibrationCommand;
            ButtplugGameVibrationRouterInterface.VibrationPingMessageReceived += OnVibrationPingMessage;
            ButtplugGameVibrationRouterInterface.VibrationExceptionReceived   += OnVibrationException;
            ButtplugGameVibrationRouterInterface.VibrationExitReceived        += OnVibrationExit;
            Task.FromResult(_bpServer.SendMessage(new RequestServerInfo("B******g Game Vibration Router")));
            _graphTab = new VibeGraphTab();
            ButtplugTab.SetOtherTab("Vibes", _graphTab);
            _processTab = new ProcessTab();
            _processTab.ProcessAttachRequested += OnAttachRequested;
            _processTab.ProcessDetachRequested += OnDetachRequested;
            ButtplugTab.SetApplicationTab("Processes", _processTab);
            ButtplugTab.AddDevicePanel(_bpServer);
            ButtplugTab.SelectedDevicesChanged += OnSelectedDevicesChanged;

            _graphTab.MultiplierChanged += MultiplierChanged;
            _graphTab.BaselineChanged   += BaselineChanged;
            _graphTab.PassthruChanged   += PassthruChanged;

            var config = new ButtplugConfig("B******g");

            ButtplugTab.GetAboutControl().CheckUpdate(config, "b******g-csharp");

            runTimer = new Timer {
                Interval = 100, AutoReset = true
            };
            runTimer.Elapsed += AddPoint;

            commandTimer = new Timer {
                Interval = 50, AutoReset = true
            };
            commandTimer.Elapsed += OnVibrationTimer;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
        }
Beispiel #14
0
        public async Task TestClientPingTimeout()
        {
            _server = new TestServer(50);
            var signal = new SemaphoreSlim(1, 1);

            // This is a test, so just ignore the logger requirement for now.
            _connector           = new ButtplugEmbeddedConnector(_server);
            _client              = new ButtplugNoPingTestClient(_connector);
            _client.PingTimeout += (aObj, aEventArgs) =>
            {
                if (signal.CurrentCount == 0)
                {
                    signal.Release(1);
                }
            };

            // We should connect, then basically be instantly disconnected due to ping timeout
            await _client.ConnectAsync();

            await signal.WaitAsync();
        }
        private ButtplugServer InitializeButtplugServer(string aServerName, uint aMaxPingTime)
        {
            // Set up internal services
            ButtplugServer bpServer;

            // Due to the weird inability to close BLE devices, we have to share device managers across b******g
            // server instances. Otherwise we'll just hold device connections open forever.
            if (_deviceManager == null)
            {
                bpServer       = new ButtplugServer(aServerName, aMaxPingTime);
                _deviceManager = bpServer.DeviceManager;
            }
            else
            {
                bpServer = new ButtplugServer(aServerName, aMaxPingTime, _deviceManager);
                return(bpServer);
            }

            if (!(Environment.OSVersion is null))
            {
                _guiLog.Info($"Windows Version: {Environment.OSVersion.VersionString}");
            }
Beispiel #16
0
 public ButtplugEmbeddedConnector(ButtplugServer aServer)
 {
     Server = aServer;
     Server.MessageReceived += OnServerMessageReceived;
 }
Beispiel #17
0
 public ButtplugEmbeddedConnector(string aServerName, uint aMaxPingTime = 0, DeviceManager aDeviceManager = null)
 {
     Server = new ButtplugServer(aServerName, aMaxPingTime, aDeviceManager);
     Server.MessageReceived += OnServerMessageReceived;
 }
 public LicenseView()
 {
     InitializeComponent();
     LicenseText.Text = ButtplugServer.GetLicense();
 }
Beispiel #19
0
 public void SetButtplugServer(ButtplugServer aServer)
 {
     _bpServer = aServer;
     _bpServer.MessageReceived += OnMessageReceived;
 }