Skip to content

Commit

Permalink
Update Program.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Apr 30, 2022
1 parent 855690d commit d12f5f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Source/CoAP.TestClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ static class Program
{
static async Task Main()
{
await SendRequestsToCoapMe();
await ObserveTradfriLamp();
//await SendRequestsToCoapMe();
}

static async Task RequestInParallelTasks()
Expand Down Expand Up @@ -272,28 +273,29 @@ static async Task ObserveTradfriLamp()

request = new CoapRequestBuilder()
.WithMethod(CoapRequestMethod.Get)
.WithPath("15001/65550")
.WithPath("15001/65557")
.Build();

response = await coapClient.RequestAsync(request, CancellationToken.None).ConfigureAwait(false);
PrintResponse(response);

request = new CoapRequestBuilder()
.WithMethod(CoapRequestMethod.Put)
.WithPath("15001/65550")
.WithPath("15001/65557")
.WithPayload("{\"3311\": [{\"5850\": 1}]}")
.Build();

response = await coapClient.RequestAsync(request, CancellationToken.None).ConfigureAwait(false);
PrintResponse(response);

var observeOptions = new CoapObserveOptionsBuilder()
.WithPath("15001/65550")
.WithPath("15001/65557")
.WithResponseHandler(new ResponseHandler())
.Build();

var observeResponse =
await coapClient.ObserveAsync(observeOptions, CancellationToken.None).ConfigureAwait(false);

PrintResponse(observeResponse.Response);

Console.WriteLine("Observed messages for lamp!");
Expand Down

0 comments on commit d12f5f4

Please sign in to comment.