-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Use Events or Streams to broadcast messages #254
Comments
done by #311 |
Is this something that could be/is exposed for an external app to take advantage? Would be very cool to be able to hack together a real-time feed for a room or something. |
@coxley, yes, the current implementation of streams that we are using is based over DDP methods and publications, so any external apps can send streams using methods and receive streams listening for publications. If you need I can explain more how to do this. |
@rodrigok If you wouldn't mind, it'd be great to learn more about how to do it! :) |
@coxley One example we have - is an external application that uses NO METEOR CODE at all. Yet, it taps the Rocket.Chat's DDP message firehose, processes, and reintroduces messages back into the system. It is only about a single page of CoffeeScript code, and dockerized - so it is easy to try and (hopefully) understand. The repo is here : Rocket.Chat Hubot Adapter Hope this is helpful :) |
If you need to handle streams manually: // Connect to Rocket.Chat via DDP
connection = DDP.connect('http://localhost:3000');
//// LISTEN EVENT
// Create a new collection to monitor typing events in remote connection
collection = new Meteor.Collection('stream-typing', connection);
// Subscribe to typing events
connection.subscribe('stream-typing');
// Handle events on add of collection and reserve an especial item of
// type subscriptionId to be used with Meteor Calls
collection.find({}).observe({
added: function(item){
if (item.type == 'subscriptionId') {
window.subscriptionId = item._id;
}
console.log(item)
}
});
//// EMIT EVENT
// Call stream on connection passing subscription id and arguments
// first argument must be event name, stream-typing is the stream name
connection.call('stream-typing', subscriptionId, ['typing', {room: 'GENERAL', username: 'rodrigo.rocket.team', start: true}]); |
@rodrigok captured for future reference ... https://github.com/RocketChat/Rocket.Chat/wiki/Real-time-messaging-APIs 😄 |
Thanks @Sing-Li, you are awesome :D |
Hello everyone. I tried @rodrigok approach but got the following error: a["{"msg":"nosub","id":"9ZFTePErqMDzvuYyv","error":{"error":404,"reason":"Subscription not found","message":"Subscription not found [404]","errorType":"Meteor.Error"}}"] Because I never get an subscriptionId, the connection.call line also fails. Any suggestions? |
@markhorsman I know very little about this, but I found with
However it seems |
Note for debian developers
The idea is to reduce the need for the merge box, broadcasting all messages of each room, and have the minimongo to update the entire message on the local collection.
Arunoda's Streams looked promising, but it discontinued
http://arunoda.github.io/meteor-streams/
https://github.com/arunoda/meteor-streams/
Maybe we could ask to become the maintained or at least fork it.
arunoda/meteor-streams#21 (comment)
Alternatives:
https://github.com/raix/Meteor-EventDDP
https://github.com/Lepozepo/meteor-streams/
The text was updated successfully, but these errors were encountered: