Skip to content

Instantly share code, notes, and snippets.

@dymurray
Created January 10, 2019 19:23
Show Gist options
  • Select an option

  • Save dymurray/80116bc57a4bac3813f4d2ee766affdc to your computer and use it in GitHub Desktop.

Select an option

Save dymurray/80116bc57a4bac3813f4d2ee766affdc to your computer and use it in GitHub Desktop.

Revisions

  1. dymurray created this gist Jan 10, 2019.
    16 changes: 16 additions & 0 deletions sse.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    var EventSource = require("eventsource")
    var source = new EventSource("https://bitgraph.network/s/ewogICJ2IjogMywKICAicSI6IHsKICAgICJmaW5kIjogeyJvdXQuYjAiOiB7ICJvcCI6IDEwNiB9LCAib3V0LmUuYSI6ICJxenc1ZWR6N3F1MDl1cHFlaHU0dHZ4ODJraGM5azAwejJ1MHRxOXU4Y2QifQogIH0sCiAgInIiOiB7CiAgICAiZiI6ICJbLltdIHwge21zZzogLm91dFswXS5zMX1dIgogIH0KfQ==");
    source.onmessage = function(event) {
    var data = JSON.parse(event.data)
    console.log(data);
    console.log(data.type);
    if (data.type == "mempool") {
    var key = data.data[0].msg;
    if (key == "z") {
    key = "A"
    }
    if (key == "x") {
    key = "B"
    }
    }
    }