| 201 | // Listens for an event, authenticating |
| 202 | // the session first. |
| 203 | function on(str, opts, cbk) { |
| 204 | cbk = (_.isFunction(opts)) ? opts : cbk; |
| 205 | cbk = cbk || function() {}; |
| 206 | opts = opts || {}; |
| 207 | ssn.server.on(str, function() { |
| 208 | if (!ssn.server || (!ssn.authenticating && !ssn.authenticated)) { |
| 209 | //console.log("Not Authenticated. Closing Session.", ssn.authenticating, ssn.authenticated); |
| 210 | self.parent._send("vantage-close-downstream", "downstream", { sessionId: ssn.id }); |
| 211 | return; |
| 212 | } |
| 213 | cbk.apply(self, arguments); |
| 214 | }); |
| 215 | } |
| 216 | |
| 217 | on("vantage-keypress-upstream", function(data) { |
| 218 | self.parent._proxy("vantage-keypress-upstream", "upstream", data).then(function(){ |