How to use the coap/common.ContentFormat.OctetStream 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
send(response, session) {
		let contentFormat = ContentFormat.OctetStream;
		switch (typeof response) {
			case 'string':
				response = ArrayBuffer.fromString(response);
				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 = [];