Commit b98e2730fff3cae6f8fcc1ee7338d45583236dcc
1 parent
892470a118
Exists in
master
avances
Showing
1 changed file
with
9 additions
and
5 deletions
Show diff stats
index.js
| ... | ... | @@ -13,16 +13,20 @@ const client = new WebSocketClient(config.urlHO); |
| 13 | 13 | client.on('open', function open() { |
| 14 | 14 | console.log('conection to socket ho is open'); |
| 15 | 15 | |
| 16 | - client.send(JSON.stringify({ gln: config.gln, action: 'gnl'})); | |
| 16 | + client.send(JSON.stringify({ gln: config.gln, action: 'gln'})); | |
| 17 | 17 | |
| 18 | 18 | client.on('message', function incoming(message) { |
| 19 | 19 | |
| 20 | - message = message.data.toString('utf8'); | |
| 20 | + message = JSON.parse(message.toString('utf8')); | |
| 21 | + | |
| 22 | + switch (message.action) { | |
| 23 | + case 'getEntity': | |
| 21 | 24 | |
| 22 | - switch (message) { | |
| 23 | - case message.action == 'getEntity': | |
| 24 | 25 | data.getEntity(message.tableName, message.where || {}).then(function(data) { |
| 25 | - client.send(data); | |
| 26 | + | |
| 27 | + message.data = data[0]; | |
| 28 | + | |
| 29 | + client.send(JSON.stringify(message)); | |
| 26 | 30 | }); |
| 27 | 31 | break; |
| 28 | 32 | default: |