public async override Task InitAsync() { var callResult = await PerformNetworkOperation(async() => { var channelId = GetChannelURI(); Debug.WriteLine("Asing for end URI: " + channelId); var wsResult = await RestClient.GetAsync <InvokeResult <string> >(channelId); if (wsResult.Successful) { var url = wsResult.Result.Result; Debug.WriteLine(url); _wsUri = new Uri(url); _webSocket = SLWIOC.Create <IWebSocket>(); _webSocket.MessageReceived += _webSocket_MessageReceived; var wsOpenResult = await _webSocket.OpenAsync(_wsUri); if (wsOpenResult.Successful) { Debug.WriteLine("OPENED CHANNEL"); } return(wsOpenResult); } else { return(wsResult.ToInvokeResult()); } }); }
public override Task InitAsync() { PerformNetworkOperation(async() => { var uri = $"/api/deployment/instance/{LaunchArgs.ChildId}"; var response = await RestClient.GetAsync <DetailResponse <DeploymentInstance> >(uri); if (response.Successful) { Instance = response.Result.Model; var hostUri = $"/api/deployment/host/{Instance.PrimaryHost.Id}"; var hostResponse = await RestClient.GetAsync <DetailResponse <DeploymentHost> >(hostUri); if (hostResponse.Successful) { Host = hostResponse.Result.Model; var hostChannelUri = $"/api/wsuri/host/{Instance.PrimaryHost.Id}/normal"; Debug.WriteLine("Asing for end URI: " + hostChannelUri); var wsResult = await RestClient.GetAsync <InvokeResult <string> >(hostChannelUri); if (wsResult.Successful) { var url = wsResult.Result.Result; Debug.WriteLine(url); var wsUri = new Uri(url); _hostWebSocket = SLWIOC.Create <IWebSocket>(); _hostWebSocket.MessageReceived += _hostWebSocket_MessageReceived;; var wsOpenResult = await _hostWebSocket.OpenAsync(wsUri); if (wsOpenResult.Successful) { Debug.WriteLine("OPENED CHANNEL"); } } EnableActions(); } else { await ShowServerErrorMessageAsync(hostResponse.ToInvokeResult()); CloseScreen(); } } else { await ShowServerErrorMessageAsync(response.ToInvokeResult()); CloseScreen(); } }); return(base.InitAsync()); }
/// <summary> /// Opens connection to a streaming API. /// </summary> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Awaitable task object for handling action completion in asynchronous mode.</returns> public Task ConnectAsync( CancellationToken cancellationToken = default) => _webSocket.OpenAsync(cancellationToken);
/// <summary> /// Opens connection to a streaming API. /// </summary> /// <returns>Awaitable task object for handling action completion in asynchronous mode.</returns> public Task ConnectAsync() => _webSocket.OpenAsync();