How to use the coap/common.Type.Ack function in coap

To help you get started, we’ve selected a few coap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kinoma / kinomajs / xs6 / sources / mc / extensions / coap / server.js View on Github external
contentFormat = ContentFormat.PlainText;
				// fallthrough
			case 'object':
				if (response instanceof ArrayBuffer) {
					response = session.createResponse(response, contentFormat);
				}
				break;
		}

		response.token = session.token;
		if (!response.code) response.code = [2, 5];

		if (!response.options) response.options = [];

		if (session.confirmable && !session.response && !session.ackSent) {
			response.type = Type.Ack;
			response.messageId = session.messageId;
		}

		if (session._observeId) {
			response.observeId = session.issueObserveId();
		}

		session.endpoint.send(response);
		session.response = response;
	}
github Kinoma / kinomajs / xs6 / sources / mc / extensions / coap / client.js View on Github external
(response, peer) => {
				let request = this.findRequest(response);
				let endpoint = this.endpoints[peer];

				if (!request || !endpoint) {
					this.transport.sendReset(response, peer);
					return;
				}

				if (response.type == Type.Con) {
					this.transport.sendAck(response, peer);
				}

				if (response.type === Type.Ack) {
					if (!request['ack']) {
						request['ack'] = Date.now();

						if (request.onAck) {
							request.onAck();
						} else if (this.onAck) {
							this.onAck(request);
						}

						endpoint.dequeue(request);
					}
				}

				if (!isEmpty(response)) {
					if (!request['response'] || request.observe) {
						request['response'] = Date.now();