Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 34 additions and 5 deletions.
  1. +3 −2 README.md
  2. +9 −1 browser.js
  3. +22 −2 lib/api.js
View
5 README.md
@@ -1,4 +1,5 @@
-node-pinoccio
+pinoccio
=============
+Pinoccio ANode.js module.
-Pinoccio Node.js module
+this is not quite ready yet. this documentation will be amazing when it is though!
View
10 browser.js
@@ -80,13 +80,21 @@ module.exports = window.pinoccioAPI = function(opts){
};
// request some or all stats by account.
- // stats are defined as a time series of reports
+ // stats are a time series of report data
// if multiple reports are provided they
api.stats = function(obj){
//
return a.stats(api.token,obj);
}
+ // get the raw events stream.
+ // to subscribe to a troops raw events you must either execute a command on a scout in that troop or watch the troop
+ // api.rest({url:"/v1/{troopid}",method:"watch"},console.log.bind(console))
+ api.events = function(){
+ //
+ return a.events(api.token);
+ }
+
return api;
}
View
24 lib/api.js
@@ -1,7 +1,7 @@
// retry rpc calls and resume streams and live streams.
// a connection is a function that returns
var through = require('through');
-//var rest = require('./resthttp');
+var json = require('./json');
var connection = require('./connection');
var repipe = require('repipe');
@@ -25,7 +25,7 @@ module.exports = function(config,reconnect){
var e = new Error("call timedout");
e.code = "E_TIMEOUT";
_cb(e);
- if(streamKey) delete expectingStream[k];
+ if(streamKey) delete o.expectingStream[streamKey];
},z.restTimeout);
var _cb = function(err,data){
@@ -114,6 +114,23 @@ module.exports = function(config,reconnect){
});
return s; // resume!
+ },
+ events:function(){
+ var s = through();
+ repipe(s,function(err,last,done){
+ if(err && err.code != 'E_MDM') return done(err);
+
+ if(last) o.start = last.key;
+ getConnection(function(err,con){
+ if(err) return done(err);
+ done(false,con.mdm.createReadStream({type:"events"}));
+ });
+ });
+
+ return s.pipe(through(function(data){
+ data = json(data);
+ if(data) this.queue(data);
+ }));
}
};
@@ -125,7 +142,10 @@ module.exports = function(config,reconnect){
if(reconnect.connected) o.connection = connection.rpc(reconnect._connection);
reconnect.on('connect',function(s){
o.connection = connection.rpc(s);
+
+ console.log('bound connection listener!');
o.connection.mdm.on('connection',function(stream){
+ console.log('mdm got stream from connection listener')
// the server has opened a stream from me.
if(stream.meta && stream.meta.type == "rest-stream") {
if(o.expectingStream[stream.meta.id]) {

No commit comments for this range

Something went wrong with that request. Please try again.