private void loadListFromFile()
        {
            //Load system's name from a file
            if (openListFileDialog.ShowDialog() == DialogResult.OK)
            {
                string srcFileName = openListFileDialog.FileName;

                using (StreamReader srcFile = new StreamReader(srcFileName))
                {
                    RemoteSystemTableHandler rSystemHandler = new RemoteSystemTableHandler();
                    string line;
                    while ((line = srcFile.ReadLine()) != null)
                    {
                        RemoteSystem rSystem = new RemoteSystem();
                        rSystem.setSystemName(line);
                        if (!rSystemHandler.exists(rSystem))
                        {
                            rSystemHandler.addSystem(rSystem);
                        }
                    }
                }
                this.displayComputerList();
                mainTabControl.SelectedTab = passwordChangeTab;
            }
        }
Example #2
0
        private async void Capabilities_Click(object sender, RoutedEventArgs e)
        {
            UpdateStatus("Checking for capabilities...", NotifyType.StatusMessage);
            appServiceSupport.Text    = "";
            launchUriSupport.Text     = "";
            spatialEntitySupport.Text = "";

            RemoteSystem selectedSystem = SystemListComboBox.SelectedItem as RemoteSystem;

            if (selectedSystem != null && selectedSystem.Status == RemoteSystemStatus.Available)
            {
                // Check and report each capability.
                await ReportCapabilityAsync(selectedSystem, KnownRemoteSystemCapabilities.AppService, appServiceSupport);
                await ReportCapabilityAsync(selectedSystem, KnownRemoteSystemCapabilities.LaunchUri, launchUriSupport);
                await ReportCapabilityAsync(selectedSystem, KnownRemoteSystemCapabilities.SpatialEntity, spatialEntitySupport);

                UpdateStatus("Successfully checked capabilities.", NotifyType.StatusMessage);
            }
            else if (selectedSystem != null && selectedSystem.Status != RemoteSystemStatus.Available)
            {
                UpdateStatus("The selected system is not available.", NotifyType.ErrorMessage);
            }
            else
            {
                UpdateStatus("Please select a system.", NotifyType.ErrorMessage);
            }
        }
        public void StartDiscovery()
        {
            if (authStatus != AuthenticationStatus.Authenticated)
            {
                throw new InvalidOperationException("Can't discover until you are authenticated");
            }

            if (remoteSystemWatcher == null)
            {
                lock (instance)
                {
                    remoteSystemWatcher = RemoteSystem.CreateWatcher();

                    //hook up event handlers
                    remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;;
                    remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;;
                    remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;;
                    remoteSystemWatcher.Complete            += RemoteSystemWatcher_Complete;
                    //start watcher
                    try
                    {
                        remoteSystemWatcher.Start();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                }
            }
        }
        //Get All Systems from the local database table
        public List <RemoteSystem> getAllSystems()
        {
            this.connect();
            List <RemoteSystem> systemsList = new List <RemoteSystem>();
            String          query           = "Select * from " + TABLE_NAME;
            SqlCeCommand    cmd             = new SqlCeCommand(query, this.conn);
            SqlCeDataReader sqlReader       = cmd.ExecuteReader();

            while (sqlReader.Read())
            {
                RemoteSystem rSystem = new RemoteSystem();

                if (!DBNull.Value.Equals(sqlReader[0]))
                {
                    rSystem.setID(sqlReader.GetInt32(0));
                }
                if (!DBNull.Value.Equals(sqlReader[1]))
                {
                    rSystem.setSystemName(sqlReader.GetString(1));
                }
                if (!DBNull.Value.Equals(sqlReader[2]))
                {
                    rSystem.setDomain(sqlReader.GetString(2));
                }
                if (!DBNull.Value.Equals(sqlReader[3]))
                {
                    rSystem.setIgnoreFlag(sqlReader.GetBoolean(3));
                }

                systemsList.Add(rSystem);
            }
            this.disconnect();
            return(systemsList);
        }
        /// <summary>
        /// Initiate Enumeration with specific RemoteSystemKind with Filters
        /// </summary>
        private async void GenerateSystemsWithFilterAsync(List <IRemoteSystemFilter> filter)
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = filter != null?RemoteSystem.CreateWatcher(filter) : RemoteSystem.CreateWatcher();

                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                if (ApiInformation.IsEventPresent("Windows.System.RemoteSystems.RemoteSystemWatcher", "EnumerationCompleted"))
                {
                    _remoteSystemWatcher.EnumerationCompleted += RemoteSystemWatcher_EnumerationCompleted;
                }
                else
                {
                    ThreadPoolTimer.CreateTimer(
                        (e) =>
                    {
                        RemoteSystemWatcher_EnumerationCompleted(_remoteSystemWatcher, null);
                    }, TimeSpan.FromSeconds(2));
                }

                _remoteSystemWatcher.Start();
            }
        }
Example #6
0
 public FileTransfer(string portNumber, int blockSize, RemoteSystem remoteSys, StorageFile file)
 {
     this.PortNumber   = portNumber;
     this.BlockSize    = blockSize;
     this.RemoteSystem = remoteSys;
     this.FileToSend   = file;
 }
        private async void DiscoverDevices()
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = RemoteSystem.CreateWatcher();

                //Add RemoteSystem to DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemAdded += async(sender, args) =>
                                                          await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Add(args.RemoteSystem));

                //Remove RemoteSystem from DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemRemoved += async(sender, args) =>
                                                            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystemId)));

                //Update RemoteSystem on DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemUpdated += async(sender, args) =>
                                                            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystem.Id));
                    DeviceList.Add(args.RemoteSystem);
                });

                _remoteSystemWatcher.Start();
            }
        }
Example #8
0
        private async void Launch_Clicked(object sender, RoutedEventArgs e)
        {
            RemoteSystem selectedSystem = SystemListComboBox.SelectedItem as RemoteSystem;

            if (selectedSystem != null)
            {
                Uri uri;
                if (Uri.TryCreate(UriTextBox.Text, UriKind.Absolute, out uri))
                {
                    UpdateStatus("LaunchUriAsync called. Waiting for response...", NotifyType.StatusMessage);

                    // Launch URI on the remote system.
                    // Note: LaunchUriAsync needs to called from the UI thread.
                    RemoteLaunchUriStatus launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(selectedSystem), uri);

                    UpdateStatus("LaunchUriStatus = " + launchUriStatus.ToString(), launchUriStatus == RemoteLaunchUriStatus.Success ? NotifyType.StatusMessage : NotifyType.ErrorMessage);
                }
                else
                {
                    UpdateStatus("Please enter a valid URI.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                UpdateStatus("Please select a system.", NotifyType.ErrorMessage);
            }
        }
Example #9
0
        async Task StartRemoteSystemDetectionAsync()
        {
            var result = await RemoteSystem.RequestAccessAsync();

            if (result == RemoteSystemAccessStatus.Allowed)
            {
                var filters = new List <IRemoteSystemFilter>()
                {
                };
                //filters.Add()
                var remoteWatcher = RemoteSystem.CreateWatcher(filters);
                remoteWatcher.RemoteSystemAdded += async(s, e) =>
                {
                    //if (!e.RemoteSystem.IsAvailableByProximity && !e.RemoteSystem.IsAvailableBySpatialProximity)
                    //    return;

                    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                                                () =>
                    {
                        Remotes.Add(e.RemoteSystem);
                    });
                };
                remoteWatcher.Start();
            }
        }
Example #10
0
        // Discovery of existing sessions
        // Handles the addition, removal, or updating of a session
        public async void DiscoverSessions()
        {
            try
            {
                RemoteSystemAccessStatus status = await RemoteSystem.RequestAccessAsync();

                // Checking that remote system access is allowed - ensure capability in the project manifest is set
                if (status != RemoteSystemAccessStatus.Allowed)
                {
                    SendDebugMessage("Access is denied, ensure the \'bluetooth\' and \'remoteSystem\' capabilities are set.");
                    return;
                }

                //  Create watcher to observe for added, updated, or removed sessions
                m_sessionWatcher          = RemoteSystemSession.CreateWatcher();
                m_sessionWatcher.Added   += RemoteSystemSessionWatcher_RemoteSessionAdded;
                m_sessionWatcher.Removed += RemoteSystemSessionWatcher_RemoteSessionRemoved;
                m_sessionWatcher.Start();
                SendDebugMessage("Session discovery started.");
            }
            catch (Win32Exception)
            {
                SendDebugMessage("Session discovery failed.");
            }
        }
Example #11
0
        public async static Task <AdventureRemoteSystem> CreateAdventureRemoteSystem(RemoteSystem system)
        {
            if (system == null)
            {
                return(null);
            }

            var appService = new AppServiceConnection()
            {
                AppServiceName    = "com.adventure",
                PackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName
            };

            RemoteSystemConnectionRequest connectionRequest = new RemoteSystemConnectionRequest(system);
            var status = await appService.OpenRemoteAsync(connectionRequest);

            if (status != AppServiceConnectionStatus.Success)
            {
                return(null);
            }

            var message = new ValueSet();

            message.Add("ping", "");
            var response = await appService.SendMessageAsync(message).AsTask().ConfigureAwait(false);

            if (response.Status != AppServiceResponseStatus.Success)
            {
                return(null);
            }

            return(new AdventureRemoteSystem(system, appService));
        }
Example #12
0
        public async Task <RomeRemoteLaunchUriStatus> LaunchUri(Uri uri, object remoteSystemOverride)
        {
            RemoteSystem rs = null;

            if (remoteSystemOverride != null)
            {
                rs = remoteSystemOverride as RemoteSystem;
                if (rs == null)
                {
                    throw new InvalidCastException();
                }
            }

            var request         = new RemoteSystemConnectionRequest(rs);
            var launchUriStatus = await RemoteLauncher.LaunchUriAsync(request, uri);

            var result = launchUriStatus.ConvertToRomeRemoteLaunchUriStatus();

            if (result == RomeRemoteLaunchUriStatus.ProtocolUnavailable)
            {
                await LaunchStoreForApp(rs);
            }

            return(result);
        }
Example #13
0
        private async Task SearchByHostNameAsync()
        {
            if (!string.IsNullOrWhiteSpace(HostNameTextBox.Text))
            {
                // Build hostname object.
                HostName hostName = new HostName(HostNameTextBox.Text);

                // Get Remote System from HostName.
                RemoteSystem remoteSystem = await RemoteSystem.FindByHostNameAsync(hostName);

                if (remoteSystem != null)
                {
                    m_rootPage.systemList.Add(remoteSystem);
                    SystemListBox.Visibility = Visibility.Visible;
                    UpdateStatus("Found system - " + remoteSystem.DisplayName, NotifyType.StatusMessage);
                }
                else
                {
                    UpdateStatus("Unable to find the system.", NotifyType.ErrorMessage);
                }
            }
            else
            {
                UpdateStatus("Enter a valid host name", NotifyType.ErrorMessage);
            }
        }
Example #14
0
        private void SearchByRemoteSystemWatcher()
        {
            if (FilterSearch.IsChecked.Value)
            {
                // Build a watcher to continuously monitor for filtered remote systems.
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher(BuildFilters());
            }
            else
            {
                // Build a watcher to continuously monitor for all remote systems.
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
            }

            // Subscribing to the event that will be raised when a new remote system is found by the watcher.
            m_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

            // Subscribing to the event that will be raised when a previously found remote system is no longer available.
            m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

            // Subscribing to the event that will be raised when a previously found remote system is updated.
            m_remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

            // Start the watcher.
            m_remoteSystemWatcher.Start();

            UpdateStatus("Searching for systems...", NotifyType.StatusMessage);
            SystemListBox.Visibility = Visibility.Visible;
        }
Example #15
0
        private async void Search_Clicked(object sender, RoutedEventArgs e)
        {
            // Disable the Search button while watcher is being started to avoid a potential
            // race condition of having two RemoteSystemWatchers running in parallel.
            Button searchButton = sender as Button;

            searchButton.IsHitTestVisible = false;

            // Cleaning up any existing systems from previous searches.
            SearchCleanup();

            // Verify access for Remote Systems.
            // Note: RequestAccessAsync needs to called from the UI thread.
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                if (HostNameSearch.IsChecked.Value)
                {
                    await SearchByHostNameAsync();
                }
                else
                {
                    SearchByRemoteSystemWatcher();
                }
            }
            else
            {
                UpdateStatus("Access to Remote Systems is " + accessStatus.ToString(), NotifyType.ErrorMessage);
            }

            searchButton.IsHitTestVisible  = true;
            DeviceInfoTextBlock.Visibility = Visibility.Visible;
        }
Example #16
0
        /// <summary>

        /// Signs in the current user.

        /// </summary>

        /// <returns></returns>



        private async void discoverDevices()
        {
            //Describes what happens when the button in the application is clicked
            //Verify Access for Remote Systems
            //RequestAccessAsync() is a method within the
            //RemoteSystem class that gets the status of calling app's access to the RemoteSystem feature
            RemoteSystemAccessStatus accessStat = await RemoteSystem.RequestAccessAsync();

            int accessInt = (int)accessStat;

            if (accessStat == RemoteSystemAccessStatus.Allowed)
            {
                //build a watcher to monitor for remote systems
                remoteSystemWatcher = RemoteSystem.CreateWatcher();
                // Start the watcher.
                remoteSystemWatcher.Start();
                //events for changes in remote system discovery
                remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
            }
            else
            {
                var errDialog = new MessageDialog("Cannot access Remote Systems.." + accessInt.ToString());
                await errDialog.ShowAsync();
            }
        }
        private async void btnGetDevices_Click(object sender, RoutedEventArgs e)
        {
            RemoteSystems.Clear();
            // Verify access for Remote Systems.
            // Note: RequestAccessAsync needs to called from the UI thread.
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus != RemoteSystemAccessStatus.Allowed)
            {
                return;
            }

            if (remoteSystemWatcher != null)
            {
                remoteSystemWatcher.Stop();
                remoteSystemWatcher = null;
            }

            // Build a watcher to continuously monitor for all remote systems.
            remoteSystemWatcher = RemoteSystem.CreateWatcher();

            remoteSystemWatcher.RemoteSystemAdded   += M_remoteSystemWatcher_RemoteSystemAdded;
            remoteSystemWatcher.RemoteSystemRemoved += M_remoteSystemWatcher_RemoteSystemRemoved;
            remoteSystemWatcher.RemoteSystemUpdated += M_remoteSystemWatcher_RemoteSystemUpdated;

            // Start the watcher.
            remoteSystemWatcher.Start();
        }
Example #18
0
        public void AddToRemoteSystemsList(RemoteSystem r)
        {
            int min = 0, max = _remoteSystems.Count;

            if (r.IsAvailableByProximity)
            {
                while (((max - 1) >= 0) && (!_remoteSystems[max - 1].IsAvailableByProximity))
                {
                    max--;
                }
            }
            else
            {
                while ((min < _remoteSystems.Count) && (_remoteSystems[min].IsAvailableByProximity))
                {
                    min++;
                }
            }

            int i;

            for (i = min; i < max; i++)
            {
                if (string.Compare(_remoteSystems[i].DisplayName, r.DisplayName) >= 0)
                {
                    break;
                }
            }
            _remoteSystems.Insert(i, r);
        }
Example #19
0
        public async Task <bool> Initialize()
        {
            if (_remoteSystemWatcher != null)
            {
                return(true);
            }

            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                // Construct a user type filter that includes anonymous devices
                //RemoteSystemAuthorizationKindFilter authorizationKindFilter = new RemoteSystemAuthorizationKindFilter(RemoteSystemAuthorizationKind.Anonymous);
                //_remoteSystemWatcher = RemoteSystem.CreateWatcher((new IRemoteSystemFilter[] { authorizationKindFilter }));

                _remoteSystemWatcher = RemoteSystem.CreateWatcher();
                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                _remoteSystemWatcher.Start();

                if (timer == null)
                {
                    timer = new Timer(Timer_Tick, null, (int)delayBeforeTimerBegin.TotalMilliseconds, (int)refreshInterval.TotalMilliseconds);
                }

                return(true);
            }

            return(false);
        }
        public async Task BuildDeviceList()
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (DeviceList != null)
                {
                    DeviceList.Clear();
                }
                RaisePropertyChanged("ShowEmptyErrorMessage");
            });

            if (m_remoteSystemWatcher != null)
            {
                m_remoteSystemWatcher.Stop();
            }
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
                // Subscribing to the event raised when a new remote system is found by the watcher.
                m_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;
                // Subscribing to the event raised when a previously found remote system is no longer available.
                m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                m_remoteSystemWatcher.Start();
            }
        }
Example #21
0
        private async void RemoteActivated(object sender, RoutedEventArgs e)
        {
            var fw = sender as FrameworkElement;

            if (fw == null)
            {
                return;
            }
            var remote = fw.DataContext as RemoteSystem;

            if (remote == null)
            {
                return;
            }


            var res = await RemoteSystem.RequestAccessAsync();

            if (res != RemoteSystemAccessStatus.Allowed)
            {
                return;
            }

            bool isRemoteSystemLaunchUriCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.LaunchUri);

            bool isRemoteSystemAppServiceCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.AppService);

            bool isRemoteSystemRemoteSessionCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.RemoteSession);

            bool isRemoteSystemSpatialEntityCapable = await remote.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.SpatialEntity);

            var rscr   = new RemoteSystemConnectionRequest(remote);
            var uri    = new Uri("http://www.google.co.uk");
            var status = await RemoteLauncher.LaunchUriAsync(rscr, uri);
        }
Example #22
0
        private async void Button3_Click(object sender, EventArgs e)
        {
            RemoteSystem rs = Common.GetCurrentRemoteSystem();

            if (rs == null)
            {
                Toast.MakeText(this, "Device not found.", ToastLength.Long).Show();
                return;
            }

            var result = await Common.PackageManager.LaunchUri(new System.Uri("http://www.ghiasi.net"), rs);

            Toast.MakeText(this, result.ToString(), ToastLength.Long).Show();

            var c = await Common.PackageManager.Connect(rs, false);

            //Fix Rome Android bug (receiver app service closes after 5 seconds in first connection)
            Common.PackageManager.CloseAppService();
            c = await Common.PackageManager.Connect(rs, false);

            //Common.PeriodicalPing();
            Dictionary <string, object> data = new Dictionary <string, object>()
            {
                { "TestLongRunning", "TestLongRunning" },
            };
            await Common.PackageManager.Send(data);
        }
Example #23
0
        public static async Task SendMessageToRemoteSystemAsync(RemoteSystem remoteSystem, string messageString)
        {
            if (await OpenAppServiceConnectionAsync(remoteSystem) == AppServiceConnectionStatus.Success)
            {
                var inputs = new ValueSet {
                    ["message"] = messageString
                };
                var response = await _appServiceConnection.SendMessageAsync(inputs);

                if (response.Status == AppServiceResponseStatus.Success)
                {
                    if (response.Message.ContainsKey("result"))
                    {
                        var resultText = response.Message["result"].ToString();

                        StatusWrite("Sent message: \"" + messageString + "\" to device: " + remoteSystem.DisplayName +
                                    " response: " + resultText);
                    }
                }
                else
                {
                    StatusWrite("Error: " + response.Status);
                }

                if (KeepConnectionOpen == false)
                {
                    CloseAppServiceConnection();
                }
            }
        }
Example #24
0
        /// <summary>
        ///     Start a session for this device/app. This will always run in the background,
        ///     allowing connecting from other devices, later if needed.
        /// </summary>
        /// <returns></returns>
        public async Task StartAsync()
        {
            // Check if we are aloud access
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus != RemoteSystemAccessStatus.Allowed)
            {
                return;
            }

            // Get device info
            var deviceInfo = new EasClientDeviceInformation();

            // Create new session of name "SoundByte on Dominic-PC" for example.
            _manager = new RemoteSystemSessionController($"SoundByte on {deviceInfo.FriendlyName}");

            // Handle joining
            _manager.JoinRequested += async(sender, args) =>
            {
                // Get the deferral
                var deferral = args.GetDeferral();

                // Run on UI thread
                await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
                {
                    var dialog = new MessageDialog($"A device ({args.JoinRequest.Participant.RemoteSystem.DisplayName}) would like to connect to SoundByte and control features such as the current playing track. Do you want to accept this connection?", "SoundByte Connect");
                    dialog.Commands.Add(new UICommand("Accept", null, 0));
                    dialog.Commands.Add(new UICommand("Cancel", null, 1));

                    dialog.CancelCommandIndex  = 1;
                    dialog.DefaultCommandIndex = 1;

                    var result = await dialog.ShowAsync();
                    if ((int)result.Id == 0)
                    {
                        args.JoinRequest.Accept();
                    }
                });

                deferral.Complete();
            };

            // Create and start the session
            var creationResult = await _manager.CreateSessionAsync();

            // Check if success, not too worried about failure
            if (creationResult.Status == RemoteSystemSessionCreationStatus.Success)
            {
                _currentSession = creationResult.Session;
                _currentSession.Disconnected += async(sender, args) =>
                {
                    await NavigationService.Current.CallMessageDialogAsync("Device disconnected: " + args.Reason, "SoundByte Connect");
                };
            }
            else
            {
                await NavigationService.Current.CallMessageDialogAsync("Failed to create session: " + creationResult.Status, "SoundByte Connect");
            }
        }
Example #25
0
        // Creates a new session, shared experience, for particpants to join
        // Handles incoming requests to join the newly created session
        public async Task <bool> CreateSession(string sessionName)
        {
            bool status = false;
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            // Checking that remote system access is allowed - ensure capability in the project manifest is set
            if (accessStatus != RemoteSystemAccessStatus.Allowed)
            {
                return(status);
            }

            m_currentSessionName = sessionName;
            SendDebugMessage($"Creating session {m_currentSessionName}...");
            var manager = new RemoteSystemSessionController(m_currentSessionName);

            // Handles incoming requests to join the session.
            manager.JoinRequested += Manager_JoinRequested;

            try
            {
                // Create session
                RemoteSystemSessionCreationResult createResult = await manager.CreateSessionAsync();

                if (createResult.Status == RemoteSystemSessionCreationStatus.Success)
                {
                    RemoteSystemSession currentSession = createResult.Session;
                    // Handles disconnect
                    currentSession.Disconnected += (sender, args) =>
                    {
                        SessionDisconnected(sender, args);
                    };

                    m_currentSession = currentSession;

                    SendDebugMessage($"Session {m_currentSession.DisplayName} created successfully.");

                    status = true;
                }
                // Session creation has reached a maximum - message user that there are too many sessions
                else if (createResult.Status == RemoteSystemSessionCreationStatus.SessionLimitsExceeded)
                {
                    status = false;
                    SendDebugMessage("Session limits exceeded.");
                }
                // Failed to create the session
                else
                {
                    status = false;
                    SendDebugMessage("Failed to create session.");
                }
            }
            catch (Win32Exception)
            {
                status = false;
                SendDebugMessage("Failed to create session.");
            }

            return(status);
        }
Example #26
0
        private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            Spinner spinner = (Spinner)sender;

            var deviceName = (string)spinner.GetItemAtPosition(e.Position);

            _selectedDevice = _remoteSystems.FirstOrDefault(d => d.DisplayName == deviceName);
        }
Example #27
0
        private AdventureRemoteSystem(RemoteSystem system, AppServiceConnection connection)
        {
            _appService  = connection;
            RemoteSystem = system;

            _appService.RequestReceived += AppService_RequestReceived;
            _appService.ServiceClosed   += AppService_ServiceClosed;
        }
Example #28
0
 private async void PingPong_OnRemoteDeviceAdded(object sender, RemoteSystem e)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         var system = new RemoteSystemInfo(e);
         RemoteSystemInfoCollection.Add(system);
     });
 }
Example #29
0
        private bool ShouldPrioritizeRomePackageManager(RemoteSystem rs)
        {
            var commPreference = CommunicationMethodPreference.WindowsCommunicationMethodPreference;

            return((rs.IsAvailableByProximity && commPreference == WindowsCommunicationMethodPreference.NativeWhenInProximity) ||
                   commPreference == WindowsCommunicationMethodPreference.Native ||
                   !CloudServiceRomePackageManager.Instance.IsInitialized);
        }
Example #30
0
 public ConfigureDialog(RemoteSystem details)
 {
     this.InitializeComponent();
     ViewModel.Details = new Models.DeviceDetails()
     {
         DeviceName = details.DisplayName, UniqueId = details.Id, Type = Helpers.RemoteSystemHelper.ConvertToDeviceType(details.Kind)
     };
 }
        // single request/response
        public static async Task<ValueSet> SendOnceAsync(RemoteSystem selectedDevice, string appServiceName, string packageFamilyName, ValueSet request)
        {
            if (selectedDevice != null)
            {
                using (AppServiceConnection connection = new AppServiceConnection { AppServiceName = appServiceName, PackageFamilyName = packageFamilyName })
                {
                    var status = await connection.OpenRemoteAsync(new RemoteSystemConnectionRequest(selectedDevice));
                    if (status == AppServiceConnectionStatus.Success)
                    {
                        var response = await connection.SendMessageAsync(request);
                        if (response.Status == AppServiceResponseStatus.Success)
                            return response.Message;
                    }
                }
            }

            return null;
        }
        public void retrieve()
        {
            //Retrieve computers from the AD server and store in the application database
            DirectoryEntry dirEntry = null;
            try
            {
                dirEntry = new DirectoryEntry("LDAP://" + AppSession.ServerIP, AppSession.UserName, AppSession.Password);
                DirectorySearcher finder = new DirectorySearcher(dirEntry);
                finder.Filter = "(objectClass=computer)";
                SearchResultCollection results = finder.FindAll();
                RemoteSystemTableHandler rSystemHandler = new RemoteSystemTableHandler();
                foreach (SearchResult sr in results)
                {
                    DirectoryEntry computerEntry = sr.GetDirectoryEntry();
                    String computerName = computerEntry.Name.Replace("CN=", "");
                    if (computerName != "")
                    {
                        RemoteSystem rSystem = new RemoteSystem();
                        rSystem.setSystemName(computerName);

                        if (!rSystemHandler.exists(rSystem))
                        {
                            rSystemHandler.addSystem(rSystem);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                this.setError("Unable to Retrieve ComputerList " + e.Message);
            }
            finally
            {
                if (dirEntry != null)
                {
                    dirEntry.Dispose();
                }
            }
        }
 public async Task LaunchOnSystem(RemoteSystem system)
 {
     BrowserPageViewModel browserVM = SimpleIoc.Default.GetInstance<BrowserPageViewModel>();
     string collectionJson = "{}";
     if (browserVM.Images is IJsonizable)
         collectionJson = (browserVM.Images as IJsonizable).toJson();
     ValueSet values = new ValueSet();
     values["images"] = collectionJson;
     values["index"] = browserVM.FlipViewIndex;
     RemoteLauncherOptions option = new RemoteLauncherOptions();
     option.FallbackUri = new Uri("https://www.microsoft.com/store/p/monocle-giraffe/9nblggh4qcvh");
     RemoteLaunchUriStatus launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(system), 
         new Uri($"imgur:?images={collectionJson}&index={browserVM.FlipViewIndex}&type={browserVM.Images.GetType().Name}"));
 }