Created
January 8, 2013 03:15
-
-
Save Raynos/4480862 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PUBNUB = require("pubnub-browserify") | |
var config = require("./config") | |
var duplex = require("pubnub-stream/duplex") | |
module.exports = communication | |
function communication(doc, channel) { | |
var client = PUBNUB.init({ | |
subscribe_key: config.subscribe_key | |
, publish_key: config.publish_key | |
}) | |
var stream = duplex(client, channel) | |
stream.pipe(doc.createStream()).pipe(stream) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crdt = require("crdt") | |
var communication = require("./communication") | |
var doc = new crdt.Doc() | |
communication(doc, "my room") | |
// And now it's synced to that room. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment