@@ -4,6 +4,7 @@ var Fibers = Npm.require('fibers');
44
55Meteor . Stream = function Stream ( name ) {
66 EV . call ( this ) ;
7+
78 var self = this ;
89 var streamName = 'stream-' + name ;
910 var allowFunction ;
@@ -18,22 +19,18 @@ Meteor.Stream = function Stream(name) {
1819
1920 self . _emit = self . emit ;
2021 self . emit = function emit ( ) {
21- var args = [ ] ;
22- for ( var key in arguments ) {
23- args . push ( arguments [ key ] ) ;
24- }
25- emitToSubscriptions ( args , null , null ) ;
22+ self . emitToSubscriptions ( arguments , null , null ) ;
2623 } ;
2724
2825 self . permissions = new Meteor . Stream . Permission ( Meteor . Collection . insecure , true ) ;
2926
30- self . addFilter = function ( callback ) {
27+ self . addFilter = function addFilter ( callback ) {
3128 filters . push ( callback ) ;
3229 } ;
3330
34- function emitToSubscriptions ( args , subscriptionId , userId ) {
31+ self . emitToSubscriptions = function emitToSubscriptions ( args , subscriptionId , userId ) {
3532 events . emit ( 'item' , { args : args , userId : userId , subscriptionId : subscriptionId } ) ;
36- }
33+ } ;
3734
3835 Meteor . publish ( streamName , function ( ) {
3936 var subscriptionId = Random . id ( ) ;
@@ -81,7 +78,11 @@ Meteor.Stream = function Stream(name) {
8178 if ( methodContext . allowed ) {
8279 //apply filters
8380 args = applyFilters ( args , methodContext ) ;
84- emitToSubscriptions ( args , subscriptionId , methodContext . userId ) ;
81+ self . emitToSubscriptions ( args , subscriptionId , methodContext . userId ) ;
82+ //send to firehose if exists
83+ if ( self . firehose ) {
84+ self . firehose ( args , subscriptionId , methodContext . userId ) ;
85+ }
8586 }
8687 //need to send this to server always
8788 self . _emit . apply ( methodContext , args ) ;
@@ -105,46 +106,4 @@ Meteor.Stream = function Stream(name) {
105106 }
106107} ;
107108
108- util . inherits ( Meteor . Stream , EV ) ;
109-
110- Meteor . Stream . Permission = function ( acceptAll , cacheAll ) {
111-
112- var options = {
113- "read" : {
114- results : { }
115- } ,
116- "write" : {
117- results : { }
118- }
119- } ;
120-
121- this . read = function ( func , cache ) {
122- options [ 'read' ] [ 'func' ] = func ;
123- options [ 'read' ] [ 'doCache' ] = ( cache === undefined ) ? cacheAll : cache ;
124- } ;
125-
126- this . write = function ( func , cache ) {
127- options [ 'write' ] [ 'func' ] = func ;
128- options [ 'write' ] [ 'doCache' ] = ( cache === undefined ) ? cacheAll : cache ;
129- } ;
130-
131- this . checkPermission = function ( type , userId , eventName ) {
132- var namespace = userId + '-' + eventName ;
133- var result = options [ type ] . results [ namespace ] ;
134-
135- if ( result === undefined ) {
136- var func = options [ type ] . func ;
137- if ( func ) {
138- result = func ( userId , eventName ) ;
139- if ( options [ type ] . doCache ) {
140- options [ type ] . results [ namespace ] = result ;
141- return result ;
142- }
143- } else {
144- return acceptAll ;
145- }
146- } else {
147- return result ;
148- }
149- } ;
150- }
109+ util . inherits ( Meteor . Stream , EV ) ;
0 commit comments