{"action":"created","issue":{"url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/4","labels_url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/4/comments","events_url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/4/events","html_url":"https://github.com/mqttjs/mqtt-stack/issues/4","id":55657944,"number":4,"title":"Adapters","user":{"login":"256dpi","id":696886,"avatar_url":"https://avatars.githubusercontent.com/u/696886?v=3","gravatar_id":"","url":"https://api.github.com/users/256dpi","html_url":"https://github.com/256dpi","followers_url":"https://api.github.com/users/256dpi/followers","following_url":"https://api.github.com/users/256dpi/following{/other_user}","gists_url":"https://api.github.com/users/256dpi/gists{/gist_id}","starred_url":"https://api.github.com/users/256dpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/256dpi/subscriptions","organizations_url":"https://api.github.com/users/256dpi/orgs","repos_url":"https://api.github.com/users/256dpi/repos","events_url":"https://api.github.com/users/256dpi/events{/privacy}","received_events_url":"https://api.github.com/users/256dpi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-27T18:47:31Z","updated_at":"2015-01-28T07:05:46Z","closed_at":null,"body":"Right now the middlewares communicate through callbacks and event emitting with higher level application code:\r\n\r\n```js\r\nvar stack = require('mqtt-stack');\r\n\r\nstack.use(new stack.BroadcastManager({\r\n  broadcastMessage: function(ctx, callback) {\r\n    // broadcast message using redis, amqp, ...\r\n  }\r\n}));\r\n```\r\n\r\nSince \"Persistence\" and \"Synchronization\" are two concerns that must be fulfilled by the application, special middlewares could enable this functionality in an extendable way:\r\n\r\n```js\r\nvar stack = require('mqtt-stack');\r\nvar redis = require('mqtt-stack-adapter-redis')\r\nvar amqp = require('mqtt-stack-adapter-amqp');\r\n\r\nvar stack = new stack.Stack();\r\n\r\n// Adapters register functions like 'storeMessage' and\r\n// 'broadcastMessage' in an internal registry\r\nstack.use(new redis.Persistence());\r\nstack.use(new amqp.Synchronization());\r\n\r\n// Falls back to the functions provided by the adapters\r\nstack.use(new stack.BroadcastManager());\r\n```"},"comment":{"url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/comments/71790354","html_url":"https://github.com/mqttjs/mqtt-stack/issues/4#issuecomment-71790354","issue_url":"https://api.github.com/repos/mqttjs/mqtt-stack/issues/4","id":71790354,"user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars.githubusercontent.com/u/52195?v=3","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"created_at":"2015-01-28T07:05:46Z","updated_at":"2015-01-28T07:05:46Z","body":"It is still not clear to me what a 'broadcast' is in this context, also 'synchronization' is definitely not the right word. maybe `amqp.Broker`?."}}