Exemple #1
0
        public async Task CancelAllActiveCommands()
        {
            using (var server = new OsmpServer()
            {
                Port = 44332
            })
                using (var client = new OsmpClient()
                {
                    Address = "wss://localhost:44332/osmp/v1"
                })
                {
                    server.Startup();
                    client.Error += (s, e) => Assert.Fail(s + "\n" + e.PrettyPrint());
                    await client.Connect();

                    // start three Standard.Wait commands
                    client.Send(Standard.Wait());
                    client.Send(Standard.Wait());
                    client.Send(Standard.Wait());
                    await client.Send(Standard.Echo()); // echo immedidatly responds, so doesn't become an active command.

                    // now get the active commands (we don't need them, we just want to know)
                    var response = await client.Send(Standard.ActiveCmds());

                    var active_cmds = response.DataAs <Standard.ActiveCmdsResult>();
                    Assert.AreEqual(3, active_cmds.Commands.Count());
                    Assert.AreEqual("wait", active_cmds.Commands.First().Name);
                    client.CancelAll();
                    // now get the active commands again to check
                    response = await client.Send(Standard.ActiveCmds());

                    active_cmds = response.DataAs <Standard.ActiveCmdsResult>();
                    Assert.AreEqual(0, active_cmds.Commands.Count());
                }
        }