private Request PerformCoAP(Request.Method method, Uri uri, Boolean messageVisible, Boolean observe)
{
if (null != _currentRequest)
_currentRequest.Cancel();
Request request = Request.Create(method);
_currentRequest = request;
request.URI = uri;
if (method == Request.Method.POST || method == Request.Method.PUT)
{
request.SetPayload(this.Payload, MediaType.TextPlain);
}
if (messageVisible)
{
request.Responding += new EventHandler<ResponseEventArgs>(request_Responding);
request.Responded += new EventHandler<ResponseEventArgs>(request_Responded);
}
request.ResponseQueueEnabled = true;
request.Execute();
return request;
}