public bool IsNoResponse(NoResponseType?messageNrt, NoResponseType result) { if (!messageNrt.HasValue) { return(false); } return(messageNrt.Value.HasFlag(result)); }
public async Task UnsubscribeAsync(string resourceUriString, NoResponseType nrt) { if (!channel.IsConnected) { await ConnectAsync(); } session.UpdateKeepAliveTimestamp(); byte[] token = CoapToken.Create().TokenBytes; ushort id = session.CoapSender.NewId(token); string scheme = channel.IsEncrypted ? "coaps" : "coap"; string coapUriString = GetCoapUriString(scheme, config.Authority, resourceUriString); CoapRequest cr = new CoapRequest(id, RequestMessageType.NonConfirmable, MethodType.DELETE, token, new Uri(coapUriString), null); cr.NoResponse = nrt; await channel.SendAsync(cr.Encode()); }
public Task PublishAsync(string resourceUriString, string contentType, byte[] payload, NoResponseType nrt) { if (!channel.IsConnected) { Open(); Receive(); } session.UpdateKeepAliveTimestamp(); byte[] token = CoapToken.Create().TokenBytes; ushort id = session.CoapSender.NewId(token); string scheme = channel.IsEncrypted ? "coaps" : "coap"; string coapUriString = GetCoapUriString(scheme, resourceUriString); CoapRequest cr = new CoapRequest(id, RequestMessageType.NonConfirmable, MethodType.POST, new Uri(coapUriString), MediaTypeConverter.ConvertToMediaType(contentType), payload) { NoResponse = nrt }; return(channel.SendAsync(cr.Encode())); }