Commit 6e69521598bd9aa9afbb86288ea52217fefad6d7

Authored by OpenWapp Developer
1 parent 364a06b011

Now triggering got_properties when the server sends the session properties

Showing 4 changed files with 26 additions and 2 deletions

samples/ffosapp/index.html View file @ 6e69521
... ... @@ -91,6 +91,7 @@
91 91 <p data-test="contacts_sync">Contacts synchronized... <span></span></p>
92 92 <p data-test="contacts_gotStatus">Contacts status received... <span></span></p>
93 93 <p data-test="presence_updated">Contact's last seen received... <span></span></p>
  94 + <p data-test="got_properties">Recieving properties... <span></span></p>
94 95  
95 96 <h4>Group signals</h4>
96 97  
samples/ffosapp/js/testing.js View file @ 6e69521
... ... @@ -84,6 +84,9 @@
84 84  
85 85 ping: null,
86 86 pong: null,
  87 + got_properties: function (properties) {
  88 + ok('got_properties');
  89 + },
87 90 disconnected: null,
88 91  
89 92 media_uploadRequestSuccess: null,
src/protocol/tree.js View file @ 6e69521
... ... @@ -91,7 +91,7 @@
91 91 };
92 92  
93 93 Tree.prototype.getAllChildren = function(tag) {
94   - var all = typeof tag !== 'undefined';
  94 + var all = typeof tag === 'undefined';
95 95 var filteredChildren = this.children.filter(function(child) {
96 96 return all || child.tag === tag;
97 97 });
src/yowsup_if.js View file @ 6e69521
... ... @@ -76,7 +76,11 @@
76 76  
77 77 var processNode = {
78 78 result: function(iqType, idx, node) {
79   - if (idx in _requests) {
  79 + var props = node.getChild('props');
  80 + if (props) {
  81 + getProperties(props.getAllChildren());
  82 + }
  83 + else if (idx in _requests) {
80 84 _requests[idx](node);
81 85 delete _requests[idx];
82 86 }
... ... @@ -126,6 +130,21 @@
126 130 }
127 131 };
128 132  
  133 + function getProperties(propertyNodes) {
  134 + var properties = {};
  135 + var stringProperties = {};
  136 + propertyNodes.forEach(function (node) {
  137 + var name = node.getAttributeValue('name');
  138 + if (name) {
  139 + properties[name] = node.getAttributeValue('value');
  140 + if (!stringProperties[name]) {
  141 + properties[name] = parseInt(properties[name], 10);
  142 + }
  143 + }
  144 + });
  145 + _signalInterface.send('got_properties', [properties]);
  146 + }
  147 +
129 148 function onError(evt) {
130 149 var reason = evt.data;
131 150 logger.error('Socket error due to:', evt, '!');
... ... @@ -1009,6 +1028,7 @@
1009 1028  
1010 1029 ping: [],
1011 1030 pong: [],
  1031 + got_properties: [],
1012 1032 disconnected: [],
1013 1033  
1014 1034 media_uploadRequestSuccess: [],