arunoda / meteor-streams

Realtime messaging for Meteor
http://arunoda.github.io/meteor-streams
MIT License
287 stars 97 forks source link

code doesn't work #5

Closed ghost closed 10 years ago

ghost commented 10 years ago

chatStream = new Meteor.Stream('chat');

if(Meteor.isClient) { sendChat = function(message) { chatStream.emit('message', message); console.log('me: ' + message); };

chatStream.on('message', function(message) { console.log('user: ' + message); }); }

There was a large blurb about autopublish being enabled so I removed it. However, I tried it with autopublish and it didn't work.

I'm using the latest meteor version 0.6.4.1

arunoda commented 10 years ago

Autopublish has nothing to do with Meteor Streams.

But if you've insecure above code should work. If you've removed it, you need to add permissions to Meteor Streams. See: http://arunoda.github.io/meteor-streams/security.html

ghost commented 10 years ago

still returns undefined from server. created new project called asdf.

mrt asdf

cd asdf

mrt add insecure mrt add streams mrt

localhost:3000

sendChat('hi'); me: hi undefined

ghost commented 10 years ago

as of now this is still not working.

arunoda commented 10 years ago

Have you tried with multiple browsers. Your chat should move to the other browsers. Anyway: Try this article, If you've not come across

ghost commented 10 years ago

still not working...it's a shame because this could be really great

=> Meteor server running on: http://localhost:5000/ W20130814-17:35:43.640(-7)? (STDERR) /Users/john/meteor/chat/.meteor/local/build/programs/server/boot.js:184 W20130814-17:35:43.733(-7)? (STDERR) }).run(); W20130814-17:35:43.733(-7)? (STDERR) ^ W20130814-17:35:43.734(-7)? (STDERR) TypeError: undefined is not a function W20130814-17:35:43.734(-7)? (STDERR) at app/chat.js:1:49 W20130814-17:35:43.734(-7)? (STDERR) at app/chat.js:14:3 W20130814-17:35:43.734(-7)? (STDERR) at mains (/Users/john/meteor/chat/.meteor/local/build/programs/server/boot.js:153:10) W20130814-17:35:43.735(-7)? (STDERR) at Array.forEach (native) W20130814-17:35:43.735(-7)? (STDERR) at Function..each..forEach (/Users/john/.meteor/tools/4010e5731d/lib/node_modules/underscore/underscore.js:79:11) W20130814-17:35:43.736(-7)? (STDERR) at /Users/john/meteor/chat/.meteor/local/build/programs/server/boot.js:80:5 => Exited with code: 1

rcy commented 10 years ago

hi @arunoda

I just followed the above mentioned tutorial, and am having problems also. I created a new app, add streams, add sample chat from your introduction page, start two browsers, and call sendChat('foo'). The .on event handler is not fired on the other browser.

Here is a log of exactly how I set up:

rcy@laird:/tmp/stream-test$ meteor --version
Release 0.6.5.1
rcy@laird:/tmp$ meteor create stream-test
stream-test: created.

To run your new app:
   cd stream-test
   meteor
rcy@laird:/tmp$ cd stream-test
rcy@laird:/tmp/stream-test$ mrt add streams
✓ streams
    tag: https://github.com/arunoda/meteor-streams.git#v0.1.15

Done installing smart packages

Stand back while Meteorite does its thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

streams: DB less realtime communication for meteor
rcy@laird:/tmp/stream-test$ wget https://gist.github.com/rcy/6434088/raw/a8fda44655b367710816e9d504d019c5bfba15be/gistfile1.js
rcy@laird:/tmp/stream-test$ cat gistfile1.js
chatStream = new Meteor.Stream('chat');

if(Meteor.isClient) {
  sendChat = function(message) {
    chatStream.emit('message', message);
    console.log('me: ' + message);
  };

  chatStream.on('message', function(message) {
    console.log('user: ' + message);
  });
}
rcy@laird:/tmp/stream-test$ meteor
[[[[[ /tmp/stream-test ]]]]]

Initializing mongo database... this may take a moment.
=> Meteor server running on: http://localhost:3000/
I20130904-01:10:21.419(-7)? ** You've set up some data subscriptions with Meteor.publish(), but
I20130904-01:10:21.463(-7)? ** you still have autopublish turned on. Because autopublish is still
I20130904-01:10:21.463(-7)? ** on, your Meteor.publish() calls won't have much effect. All data
I20130904-01:10:21.463(-7)? ** will still be sent to all clients.
I20130904-01:10:21.464(-7)? **
I20130904-01:10:21.464(-7)? ** Turn off autopublish by removing the autopublish package:
I20130904-01:10:21.464(-7)? **
I20130904-01:10:21.464(-7)? **   $ meteor remove autopublish
I20130904-01:10:21.464(-7)? **
I20130904-01:10:21.464(-7)? ** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls
I20130904-01:10:21.465(-7)? ** for each collection that you want clients to see.
ghost commented 10 years ago

were you able to get this running? still not working and no action from author....

rcy commented 10 years ago

@jjk3 no I haven't. Waiting to discuss with @arunoda, or when I get more time, will debug further.

ghost commented 10 years ago

did you get a chance to discuss?

arunoda commented 10 years ago

Guys sorry for not following up. Had some busy time with SmartCollections. Please remove autopublish and add insecure package.

This should work. If not give me you code. And content of .meteor/packages.

Also tell me which meteor version using and the os.

ghost commented 10 years ago

it was never working....honestly I feel like a broken record here. I was looking forward to use this but simply can't use it at the moment.

rcy commented 10 years ago

@arunoda thanks for following up. I created a minimal app demonstrating the issue, https://github.com/rcy/meteor-streams-issue-5-repro

I am using meteor 0.6.5.1, I removed autopublish, and kept insecure.

arunoda commented 10 years ago

Great. Let me check now.

On Wed, Sep 11, 2013 at 11:48 PM, Ryan Yeske notifications@github.comwrote:

@arunoda https://github.com/arunoda thanks for following up. I created a minimal app demonstrating the issue, https://github.com/rcy/meteor-streams-issue-5-repro

I am using meteor 0.6.5.1, I removed autopublish, and kept insecure.

— Reply to this email directly or view it on GitHubhttps://github.com/arunoda/meteor-streams/issues/5#issuecomment-24263463 .

Arunoda Susiripala

@arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda

arunoda commented 10 years ago

Yes. There is an issue. With the latest meteor versions insecure works differently. I've not updated streams with that.

Anyway for now. You can add permissions and make this works. (Actually you need to add permissions in a real app)

Add following code and it works

if(Meteor.isServer) {
  chatStream.permissions.read(function() {
    return true;
  });

  chatStream.permissions.write(function() {
    return true;
  });
}
arunoda commented 10 years ago

Fixed with ebb9f3a243072139ea644fd7ce68916b7cb8f446 and published as 0.1.16

rcy commented 10 years ago

I did a mrt update, and it works as expected. Thanks @arunoda

arunoda commented 10 years ago

Awesome. I think I can close the issue now.