Code Monkey home page Code Monkey logo

coap-polyfill's Introduction

CoAP Polyfill

This plugin enables the creation of CoAP request using client side javascript running in the browser. On the client side this plugin provides an CoAPRequest object with an API similar to the XMLHttpRequest. The CoAPRequest object forwards the request definition to a proxy server running on the clients machine using HTTP. The server performs the CoAP request on behalf of the client and return the response.

Usage

The CoAP polyfill can be enabled by including the coap.js file hosted by the proxy server.

<script src="http://localhost:8080/coap.js" type="application/javascript"></script>

Simple coap get request:

var request = new CoapRequest();
request.open('GET', 'coap://localhost:5683', true);
request.onload = function () {
  alert(request.responseText);
};
request.send();

Coap requests can also be created using the jQuery API.

$.get("coap://localhost:5683", function( data ) {
    alert(data);
});

Security

The current version of this pluign should only be used for development purposes. To simplify the exchange of web applications using CoAP requests, the proxy server accepts cross-origin requests. Thereby, enabling any website to create CoAP requests (if the proxy server is running on the clients machine).

The security can be improved by implementing an origin based autorization process, where the user needs to allow the site to access a specific CoAP endpoint (device/service).

Examples

Features

  • Observer resources (using websockets)
  • Access permission model
  • GET, POST, PUT and DELETE requsts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.