Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Created January 19, 2020 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsh-code/a378381d32f4c386673f3cf4792c15f2 to your computer and use it in GitHub Desktop.
Save tsh-code/a378381d32f4c386673f3cf4792c15f2 to your computer and use it in GitHub Desktop.
const redis = require("redis");
const subscriber = redis.createClient({
url: "redis://localhost:6379"
});
const publisher = subscriber.duplicate();
const WS_CHANNEL = "ws:messages";
subscriber.on("message", (channel, message) => {
console.log(`Message from: ${channel}, ${message}`);
});
subscriber.subscribe(WS_CHANNEL);
publisher.publish(WS_CHANNEL, "my message");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment