/// <summary> /// Send Message from Client to Host (such as ink data) /// </summary> public Task <ValueSet> SendMessageFromClientAsync(ValueSet message, SlideshowMessageTypeEnum queryType) { if (_remoteSystem == null || message == null) { return(null); } message.Add("type", queryType.ToString()); message.Add("query", ConnectedServiceQuery.MessageFromClient.ToString()); return(_remoteSystem.SendMessage(message)); }
/// <summary> /// Initiates the second screen experience on the client if the system is showing a slideshow /// </summary> /// <param name="system"></param> /// <returns>Message from system with what adventure and current slide number</returns> public async Task <ValueSet> ConnectToSystem(AdventureRemoteSystem system) { ValueSet message = new ValueSet(); message.Add("query", ConnectedServiceQuery.StartHostingSession.ToString()); var response = await system.SendMessage(message); if (response != null && response.ContainsKey("success") && (bool)response["success"]) { var status = (ConnectedServiceStatus)Enum.Parse(typeof(ConnectedServiceStatus), (String)response["status"]); if (status != ConnectedServiceStatus.HostingNotConnected && status != ConnectedServiceStatus.HostingConnected) { return(null); } message.Clear(); if (_remoteSystem != system) { if (_remoteSystem != null) { _remoteSystem.MessageReceived -= _remoteSystem_MessageReceived; _remoteSystem = null; } _remoteSystem = system; _remoteSystem.MessageReceived += _remoteSystem_MessageReceived; } response = await SendMessageFromClientAsync(message, SlideshowMessageTypeEnum.Status); if (response == null) { _remoteSystem = null; _remoteSystem.MessageReceived -= _remoteSystem_MessageReceived; return(null); } return(response); } return(null); }
/// <summary> /// Start the slideshow on the remote system /// </summary> /// <param name="system"></param> /// <param name="deepLink"></param> /// <returns></returns> public async Task <bool> ConnectToSystem(AdventureRemoteSystem system, string deepLink = "") { ValueSet message = new ValueSet(); message.Add("query", ConnectedServiceQuery.StartHostingSession.ToString()); var response = await system.SendMessage(message); if (response != null && response.ContainsKey("success") && (bool)response["success"]) { var status = (ConnectedServiceStatus)Enum.Parse(typeof(ConnectedServiceStatus), (String)response["status"]); if (status != ConnectedServiceStatus.HostingNotConnected && status != ConnectedServiceStatus.HostingConnected) { var launchUriStatus = await RemoteLauncher.LaunchUriAsync( new RemoteSystemConnectionRequest(system.RemoteSystem), new Uri("adventure:" + deepLink)).AsTask().ConfigureAwait(false); if (launchUriStatus != RemoteLaunchUriStatus.Success) { return(false); } } if (_remoteSystem != system) { if (_remoteSystem != null) { _remoteSystem.MessageReceived -= _remoteSystem_MessageReceived; _remoteSystem = null; } _remoteSystem = system; _remoteSystem.MessageReceived += _remoteSystem_MessageReceived; } return(true); } return(false); }