public IdentifyViewModel(IFaceServiceClient client, IDialogService dialogService) { this.client = client; var fileSelector = new ObservableFileSelector(); var imageSelector = new ImageSelector(fileSelector.SelectFilesCommand); detector = new Detector(client); SelectFilesCommand = fileSelector.SelectFilesCommand; var filesObs = SelectFilesCommand.Publish(); IdentifyCommand = ReactiveCommand.CreateFromTask(IdentifyFaces, imageSelector.Images.Any()); imagesObs = imageSelector.Images .Select(list => list.Select(data => new IdentificationViewModel(data.Image, data.Source)).ToList()) .ToProperty(this, model => model.Identifications); IdentifyCommand.Subscribe(SetIdentifications); IdentifyCommand.ThrownExceptions.Subscribe(async exception => await dialogService.ShowException(exception)); isBusyObs = IdentifyCommand.IsExecuting.ToProperty(this, model => model.IsBusy); filesObs.Connect(); }
public void Identify_RepositoryOverHttp_ReturnsRevSpec() { IdentifyCommand cmd = new IdentifyCommand().WithPath("https://hg01.codeplex.com/mercurialnet"); NonPersistentClient.Execute(cmd); Assert.That(cmd.Result, Is.Not.Null); }
public void Identify_RepositoryOverHttp_ReturnsRevSpec() { IdentifyCommand cmd = new IdentifyCommand().WithPath("https://hg01.codeplex.com/mercurialnet"); NonPersistentClient.Execute(cmd); Assert.That(cmd.Result, Is.Not.Null); }
/// <summary> /// The Identify Command /// /// The identify command starts or stops the receiving device identifying itself. /// /// <param name="identifyTime" <see cref="ushort"> Identify Time</ param > /// <returns> the command result Task </returns> /// </summary> public Task <CommandResult> IdentifyCommand(ushort identifyTime) { IdentifyCommand command = new IdentifyCommand(); // Set the fields command.IdentifyTime = identifyTime; return(Send(command)); }
private void IdentifyAs(RemoteTcpServer serverEntity, string name) { var cmd = new IdentifyCommand() { Name = name }; serverEntity.Send(cmd); var response = serverEntity.WaitForNextCommand <IdentifyResponse>(); Assert.IsTrue(response.Success); serverEntity.Name = name; }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, MercurialPluginProfile settings) { settings.ValidateUri(errors); if (!errors.Any()) { var identifyCommand = new IdentifyCommand().WithPath(settings.Uri).WithTimeout(20); NonPersistentClient.Execute(identifyCommand); if (identifyCommand.RawExitCode != 0) { throw new Exception("Can't establish connection"); } } }
public void Identify_WebSiteThatIsntRepository_ThrowsMercurialExecutionException() { try { new WebClient().DownloadString("http://localhost"); } catch (WebException) { Assert.Inconclusive("No web server set up locally, test not executed"); return; } IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhost"); Assert.Throws<MercurialExecutionException>(() => NonPersistentClient.Execute(cmd)); }
public void SendIdentify(string token) { var props = new Dictionary <string, string> { ["$device"] = "Discord.Net" }; var msg = new IdentifyCommand() { Token = token, Properties = props, LargeThreshold = _config.LargeThreshold, UseCompression = true }; QueueMessage(msg); }
public void Identify_WebSiteThatIsntRepository_ThrowsMercurialExecutionException() { try { new WebClient().DownloadString("http://localhost"); } catch (WebException) { Assert.Inconclusive("No web server set up locally, test not executed"); return; } IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhost"); Assert.Throws <MercurialExecutionException>(() => NonPersistentClient.Execute(cmd)); }
public void SendIdentify(string token) { var props = new Dictionary <string, string> { ["$device"] = "Discord.Net" }; var msg = new IdentifyCommand() { Version = 3, Token = token, Properties = props, LargeThreshold = _client.Config.UseLargeThreshold ? 100 : (int?)null, UseCompression = true }; QueueMessage(msg); }
public void SendIdentify(string token, int shardId = 0, int totalShards = 1) { var props = new Dictionary <string, string> { ["$device"] = "Discord.Net" }; var msg = new IdentifyCommand() { Token = token, Properties = props, LargeThreshold = _config.LargeThreshold, UseCompression = true, ShardingParams = token.StartsWith("Bot ") ? new int[] { shardId, totalShards } : null }; QueueMessage(msg); }
public IdentifyCommandCases() { _IdentifyCommand = new IdentifyCommand(); _Command = _IdentifyCommand; }
private static void CompareIdentifyCommand(IdentifyCommand c, IdentifyCommand dc) { Assert.AreEqual(c.Name, dc.Name); }
public void Identify_WebSiteThatDoesNotExist_ThrowsMercurialExecutionException() { IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhostxyzklm"); Assert.Throws <MercurialExecutionException>(() => NonPersistentClient.Execute(cmd)); }
private void IdentifyAs(RemoteTcpServer serverEntity, string name) { var cmd = new IdentifyCommand() { Name = name }; serverEntity.Send(cmd); var response = serverEntity.WaitForNextCommand<IdentifyResponse>(); Assert.IsTrue(response.Success); serverEntity.Name = name; }
public void Identify_WebSiteThatDoesNotExist_ThrowsMercurialExecutionException() { IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhostxyzklm"); Assert.Throws<MercurialExecutionException>(() => NonPersistentClient.Execute(cmd)); }
public override async Task Connect() { // Connect to the gateway socket = new ClientWebSocket(); var uri = new Uri(DefaultGateway); await socket.ConnectAsync(uri, CancellationToken.None); _log.Info("Connected to a Discord socket."); // Receive 10 Hello var response = await ReceiveMessage(); if (response.OpCode != (int)MainOpCodeTypes.Hello) { throw new WebSocketException("Socket Out of Order: First message not OpCode 10, Hello."); } var hello = response.DeserializeDataPayload <HelloPayload>(); // Set up messaging systems SendMessagesAgentAsync(); ReceiveMessagesAgentAsync(); _log.Debug("Started messaging systems."); // Send 1 Heartbeat (and continue to do so) heart = new MainGatewayHeart(hello.HeartbeatInterval, this); _log.Debug("Started heartbeat."); // Send 2 Identify var identify = new IdentifyCommand { Data = { AuthenticationToken = authorizationToken, ConnectionProperties = { OperatingSystemName = "windows", BrowserName = "mjolnir", DeviceName = "mjolnir", }, AllowCompression = false, ConnectionPresence = { ConnectionGame = { Name = "\"PUNCH LINE!\" by Shokotan ♥ Denpa Gumi", }, Status = "online", } } }; await SendMessage(JsonConvert.SerializeObject(identify)); Console.WriteLine(JsonConvert.SerializeObject(identify)); _log.Debug("Sent identity."); // Receive 0 Ready var ready = await readyResponseSource.Task; _log.Info($"Current User: {ready.CurrentUser.Username}"); _log.Info($"Accessible DMs: {ready.AssociatedDirectMessageChannels.Select(c => c.Name).ToSequenceString()}"); _log.Info($"Accessible Guilds: {ready.AssociatedGuilds.Select(g => g.Id).ToSequenceString()}"); currentUser = ready.CurrentUser; sessionId = ready.SessionId; _log.Info($"Fully connected."); }
private static void CompareIdentifyCommand(IdentifyCommand c, IdentifyCommand dc) { Assert.AreEqual(c.Name, dc.Name); }