//on receive observe response void observe_Responded(Object sender, ResponseEventArgs e) { if (coapWebSocektService.SessionList.Contains(observedSession)) { coapWebSocektService.SendToObserved(e.Response.PayloadString, observedSession); } //when the client is closed,cancel the observe else { PerformCoAP(Request.Method.GET, _observingRequest.URI, false, false); Console.WriteLine("Websocket链接关闭"); this.clientSocket.Disconnect(false); this.clientSocket.Dispose(); } }