How to use the coap.Server 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 / pins / pins__coap.js View on Github external
init(port, configuration) {
		this.repeats = [];

		this.coap = new Server();
		this.coap.configuration = configuration;

		this.coap.bind('/invoke', session => {
			let requestObject;
			if (session.payload) {
				requestObject = JSON.parse(String.fromArrayBuffer(session.payload));
			}

			session.autoAck = false;

			const path = parseQuery(session).path;
			const cb = result => {
				const response = session.createResponse();
				if (result !== undefined) {
					if (result instanceof ArrayBuffer)
						response.setPayload(result, "application/octet-stream");