private static void CleanAll(string[] cmds)
        {
            CoapClient            c = new CoapClient(Program.Host);
            IEnumerable <WebLink> d = c.Discover("rt=core.rd*", MediaType.ApplicationLinkFormat);

            string endpointRegister = null;
            string endpointLookup   = null;
            string groupRegister    = null;
            string groupLookup      = null;
            string resourceLookup   = null;

            foreach (WebLink w in d)
            {
                foreach (string s in w.Attributes.GetResourceTypes())
                {
                    switch (s)
                    {
                    case "core.rd":
                        endpointRegister = w.Uri;
                        break;

                    case "core.rd-lookup-res":
                        resourceLookup = w.Uri;
                        break;

                    case "core.rd-group":
                        groupRegister = w.Uri;
                        break;

                    case "core.rd-lookup-gp":
                        groupLookup = w.Uri;
                        break;

                    case "core.rd-lookup-ep":
                        endpointLookup = w.Uri;
                        break;
                    }
                }
            }

            if (groupLookup != null)
            {
                d = c.Discover(groupLookup, null, MediaType.ApplicationLinkFormat);
                foreach (WebLink w in d)
                {
                    c.UriPath = w.Uri;
                    c.Delete();
                }
            }

            d = c.Discover(endpointLookup, null, MediaType.ApplicationLinkFormat);
            foreach (WebLink w in d)
            {
                c.UriPath = w.Uri;
                c.Delete();
            }
        }
        static void RunTest12(string[] cmds)
        {
            //  Do it as a third party.
            CoapClient cl = new CoapClient(Program.Host)
            {
                UriPath = Test3Location,
                Timeout = 20 * 1000
            };
            Response r1 = cl.Delete();

            if (r1 == null)
            {
                Console.WriteLine("No response message retrieved");
                return;
            }

            if (r1.StatusCode != StatusCode.Deleted)
            {
                Console.WriteLine("Incorrect return code");
            }

            Console.WriteLine(Utils.ToString(r1));
        }
Ejemplo n.º 3
0
        static void RunTest11()
        {
            CoapClient request = new CoapClient(Program.Host + "/oscore/test")
            {
                Timeout       = 2000,
                OscoreContext = _oscoreContext
            };

            Response response = request.Delete();


            if (response == null)
            {
                Console.WriteLine("Failed to receive response");
                return;
            }

            if (response.StatusCode != StatusCode.Deleted)
            {
                Console.WriteLine($"Content type should be 2.02 not {response.StatusCode}");
            }

            Console.WriteLine($"Response Message:\n{Utils.ToString(response)}");
        }