Ejemplo n.º 1
0
        private void _OnReceiveMessage(IConnection connection, byte[] message)
        {
            RemoteXControlMessage[] datas = null;
            try
            {
                datas = RemoteXControlMessage.FromBytes(message);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine("XJ2::" + exception.Message);
            }
            ControllerManager controllerManager = controllerManagers[connection];

            if (datas != null)
            {
                foreach (var data in datas)
                {
                    controllerManager.addData(data);
                    DebugBackend.Instance.Set(data);
                    Debug.WriteLine(data);
                }
            }
        }
Ejemplo n.º 2
0
        //这个站且用来测试鼠标移动,以下就是他妈的移动方法。
        private void Button_BluetoothInitialize_Click(object sender, RoutedEventArgs e)
        {
            /*
             * BTTaskManager btTaskManager = BTTaskManager.instance;
             * btTask = btTaskManager.newTask();
             * btTask.onReceiveMessage += onReceiveData;
             * Debug.WriteLine("UI::" + Thread.CurrentThread.ManagedThreadId);
             * btTask.startAdvertising();
             * ControllerManager controllerManager = new ControllerManager();
             *
             * ImageSource is_QRCode = BitmapToBitmapImage(btTask.QRCode);
             * img_QRCode.Source = is_QRCode;
             * controllerManager = new ControllerManager();*/

            ControllerManager controllerManager = new ControllerManager();
            BluetoothManager  bluetoothManager  = BluetoothManager.Instance;
            var bluetoothServerConnection       = bluetoothManager.CreateRfcommServerConnection(Guid.Parse("14c5449a-6267-4c7e-bd10-63dd79740e5" + 0));

            bluetoothServerConnection.OnConnectionEstalblishResult += OnConnectionEstalblishResult;
            bluetoothServerConnection.OnReceiveMessage             += _OnReceiveMessage;
            bluetoothServerConnection.StartServer();
            controllerManagers.Add(bluetoothServerConnection, controllerManager);
        }