Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code doesn't work #5

Closed
ghost opened this issue Aug 2, 2013 · 17 comments
Closed

code doesn't work #5

ghost opened this issue Aug 2, 2013 · 17 comments

Comments

@ghost
Copy link

ghost commented Aug 2, 2013

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
Copy link
Owner

arunoda commented Aug 2, 2013

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
Copy link
Author

ghost commented Aug 2, 2013

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
Copy link
Author

ghost commented Aug 6, 2013

as of now this is still not working.

@arunoda
Copy link
Owner

arunoda commented Aug 6, 2013

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
Copy link
Author

ghost commented Aug 15, 2013

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
Copy link

rcy commented Sep 4, 2013

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
Copy link
Author

ghost commented Sep 5, 2013

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

@rcy
Copy link

rcy commented Sep 5, 2013

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

@ghost
Copy link
Author

ghost commented Sep 10, 2013

did you get a chance to discuss?

@arunoda
Copy link
Owner

arunoda commented Sep 11, 2013

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
Copy link
Author

ghost commented Sep 11, 2013

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
Copy link

rcy commented Sep 11, 2013

@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
Copy link
Owner

arunoda commented Sep 12, 2013

Great. Let me check now.

On Wed, Sep 11, 2013 at 11:48 PM, Ryan Yeske [email protected]:

@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//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
Copy link
Owner

arunoda commented Sep 12, 2013

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
Copy link
Owner

arunoda commented Sep 12, 2013

Fixed with ebb9f3a and published as 0.1.16

@rcy
Copy link

rcy commented Sep 12, 2013

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

@arunoda
Copy link
Owner

arunoda commented Sep 12, 2013

Awesome. I think I can close the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants