octoblu / meshblu

Meshblu is a cross-protocol IoT machine-to-machine messaging system.
https://meshblu.readme.io/
MIT License
816 stars 181 forks source link

Forwarder of webhook #134

Open KimALam opened 8 years ago

KimALam commented 8 years ago

Hi~ Recently, I got a necessity of data forwarder. So, to know how to use it and verify it works properly, I used https://github.com/octoblu/data-forwarder-mongodb

But I recognized it does not work corretly. So, digged into meshblu, and found some clues and fixed those. However, I'm not a meshblu developer, so I am not sure it's fine. My fixing is below to run https://github.com/octoblu/data-forwarder-mongodb

1) lib/SubscriptionGetter.coffee

8, 9 line has function name of "broadcast" and "config", but does not have about "received". So, I appended received: 'canReceive' to _SECURITYMAP

@SECURITY_MAP: broadcast: 'canReceive' config: 'canDiscover' received: 'canReceive'

2) src/publish-forwarder.coffee

structure of meshblu.forwarder is

"meshblu": { "version": "2.0.0", "forwarders": { "message": { "received": [...] }, "broadcast": { "received": [...] } },

so I fix the code forwarders = attributes.meshblu?.forwarders?[type] || [] to forwarders = attributes.meshblu?.forwarders?.message?[type] || []

3) src/controllers/device-controller.coffee in https://github.com/octoblu/data-forwarder-mongodb

fix messageReceived = {subscriberUuid: uuid, emitterUuid: uuid, type: 'message.received'} broadcastReceived = {subscriberUuid: uuid, emitterUuid: uuid, type: 'broadcast.received'} to messageReceived = {subscriberUuid: uuid, emitterUuid: uuid, type: 'received'} broadcastReceived = {subscriberUuid: uuid, emitterUuid: uuid, type: 'broadcast'}

4) example.sh in https://github.com/octoblu/data-forwarder-mongodb

fix the type of message.received to received

_meshblu-util subscription-create -s $FORWARDER_DEVICE_UUID -e $RECEIVER_DEVICEUUID -t received ./tmp/data-forwarder-meshblu.json

I just tested it and had proper work. Could you scrutinize that it is suitable? Thanks in advance.

p.s) If you want, I can give diff.