11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node-red用websocketブリッヂ その2

Posted at

#概要
node-redのwebsocketからmilkcocoaにつなぐ、ブリッヂをjsdo.it上に構築した。
ライブラリーは、milkcocoa.jsを使った。
#写真
websocket.jpg

#サンプルコード

var red;
var mlk;
var ds;
function setup() {
    var url = "flagi9edsvtg.mlkcca.com";
    red = new WebSocket("ws://node-red/test0");
    red.onmessage = function(e) {
        //alert("red received data : " + e.data);
        ds.push({
            content: "ohisama",
            date: new Date().getTime()
        });
    };
    mlk = new MilkCocoa(url);
    var ds = mlk.dataStore("message");
    ds.on("push", function(e) {
        //alert("ds on");
        red.send("ohisama");
    });
}
setup();
11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?