Giter Site home page Giter Site logo

meteor-streamer's Introduction

RocketChat:Streamer

2 way communication over DDP with better performance.

Installation

meteor add rocketchat:streamer

Documentation

package documentation

History

1.0.2 (2019-05-19)

  • Do not use super to call parent classes (fix for Edge browser)

1.0.1 (2018-10-24)

  • Throw an error if subscribe not allowed

1.0.0 (2018-10-24)

  • Allow better way to override publish method
  • Avoid multiple DDPCommon.stringifyDDP for multiple subscriptions
  • Refactor to call unsub on removeListener

0.5.0 (2016-06-07)

  • Add a new method to control data flow allowEmit

0.4.0 (2016-05-21)

  • Added optional ddpConnection to Streamer constructor

0.3.5 (2016-05-02)

  • Fix some ES6 errors

0.3.4 (2016-05-01)

  • Remove all listeners on unsubscribe

meteor-streamer's People

Contributors

buddhikajay avatar ejfrancis avatar ggazzo avatar maxnowack avatar nullpo avatar pagebakers avatar rodrigok avatar sampaiodiego avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-streamer's Issues

Match error: Expected string, got null

yesterday, I've migrated from arunoda's package to rocketchat:streamer. Sometimes, I get the following Exception:

Error: Match error: Expected string, got null
    at exports.check (packages/check/match.js:34:1)
    at Subscription.<anonymous> (packages/rocketchat:streamer/server/server.js:264:4)
    at packages/matb33_collection-hooks/collection-hooks.js:275:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at Subscription._handler (packages/matb33_collection-hooks/collection-hooks.js:274:1)
    at packages/check/match.js:107:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at Object.exports.Match._failIfArgumentsAreNotAllChecked (packages/check/match.js:106:1)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1701:18)
    at Subscription._runHandler (packages/ddp-server/livedata_server.js:1026:17) 

It seems like the null was passed as the eventName to the streamer subscription. I always pass an eventName to the on method of a stream. Do you have an idea whats going on here?

How to communicate between servers

FEATURE REQUEST
Re-opening this with apologies.
I'm using Meteor Streamer in my app ( it's a core feature and works well thanks) but now have a need to use it from server (acting as a client) to server (acting as master). This scenario is allowed by DDP and is explicitly referenced here (https://guide.meteor.com/structure.html#sharing-data)
and of course one server can happily call another server's Method over DDP.

So I start with a question as to whether there is any inherent reason why Streamer could not do this?

[In my understanding the recent change to Meteor-Streamer to allow connection to multiple servers does not allow one server, acting as a client, to subscribe to a master server. The Streamer seems to be declared not in common code, but with distinctions for client and server code.]

I can also reference this
which added multi-server capability to Arunoda-Streams with a common code approach to declaration (as per Collections) and possibly allowing server-server connections (not sure about this).

USE CASE
Why is server-server needed? I refer to my use case...
My application is built for real-time instrumentation - typically about 256 packets per second, each packet being about 10 bytes. [DDP/Streamer is comfortable doing this and the efficiency is not outrageously bad.]

There is a meteor server on the PC adjacent to the Instrument for two reasons

  • the server is needed to give the web app access to the USB ports
  • the data needs to get to the adjacent web app with minimal jitter (300mS max - for logging etc)), whilst other clients, remote to the instrument, can more loosely monitor the data and can absorb web latency, but they do need to have the ability to command the instrument - >> and this is the blockage <<.

My current implementation is for the local server adjacent to the instrument to take the data and send to the adjacent client via Streamer. In parallel, it calls a method on a central server to send a packet of instrument data to that central server which then broadcasts the data via a second, globally accessible Streamer. This works ok since we know the fixed web address of the central server.

The problem arises in the the other direction when global clients want to send commands to the instrument. We cannot use methods without NAT complicating address finding for local instrument servers in the network (there will be many). A Streamer created by the Local Server would overcome this issue, and also the transport of the instrument data would be more efficient (than calling methods).

It seems that to transport a press of a button on the instrument I will be needing to use Collections. Possible, but overkill I think.

bruce.

Horizontal scaling support on (Meteor) Galaxy Server

Hello,

We are working on a project (just like an chatting app) based on meteor and hosted on Galaxy server, and using "rocketchat:streamer" to establish communication b/w multiple devices.

It works fine if the app is deployed on single container but if we scale the app horizontally i.e. if we create more than one container it breaks the functionality, a device connected to one container can't communicate with device connected to other container.

We are not using database for any reason, just emits events with a uniqe string and perform tasks
if a perticular events matches,

Following is code...

const streamer = new Meteor.Streamer('streamer_name');
streamer.emit("unique_pin", {
event: 'anyEventName',
...
});

streamer.on("unique_pin", (data) => {
const { event } = data;
if (event === 'anyEventName') {
// Do some task if event matches
}
}

Thanks

Allow alternate ddp connection

Allow a ddp connection object to be provided to the Meteor.Streamer constructor to override the default Meteor.connection

Error "Method not found" when run test example

please help me check this:
I create new meteor project and add rocketchat:streamer.
When i try "chat" example. web socket return error:
:
"{"msg":"result","id":"2","error":{"error":404,"reason":"Method 'stream-chat' not found","message":"Method 'stream-chat' not found [404]","errorType":"Meteor.Error"}}"
And
{"msg":"nosub","id":"EDYWftj5NP37ykrCp","error":{"error":404,"reason":"Subscription 'stream-chat' not found","message":"Subscription 'stream-chat' not found [404]","errorType":"Meteor.Error"}}

My "meteor list" here:
accounts-password 1.3.4 Password support for accounts
accounts-ui 1.1.9 Simple templates to add login widgets to an app
blaze-html-templates 1.1.0 Compile HTML templates into reactive UI with Me...
ecmascript 0.6.3 Compiler plugin that supports ES2015+ in all .j...
jquery 1.11.10 Manipulate the DOM using CSS selectors
meteor-base 1.0.4 Packages that every Meteor app needs
mobile-experience 1.0.4 Packages for a great mobile user experience
mongo 1.1.15 Adaptor for using MongoDB and Minimongo over DDP
reactive-var 1.0.11 Reactive variable
rocketchat:streamer 0.5.0 DB less realtime communication for meteor
session 1.1.7 Session variable
shell-server 0.2.3 Server-side component of the meteor shell com...
standard-minifier-css 1.3.4 Standard css minifier used with Meteor apps by ...
tracker 1.1.2 Dependency tracker to allow reactive callbacks

Horizontal Scaling

Thanks for the great package!

I had a quick inquiry. Does this package support horizontal scaling? I read that the arunoda meteor streams package did not support it, and I need to implement this on more than one Galaxy container in the same app.

If not, are there any suggested ways to implement it?

Not working on Safari

Hi,

I used this in one of the projects and it's great to have it. The only concern I have is it's not working on Safari.

Please provide a solution to this issue if anyone experienced the same

Adaption for Asteroid

I am extending my video chat extension to work as an Asteroid (Alternative Meteor Client) mixin and at present, this package is a dependency. Is there any desire for this to be extended to work with Asteroid (I have done most of the work, I can create a PR if need be).

How can I keep track data after offline or reconnection?

On readme page, in downsides section written that "Since the library don't keep track of data, you will not receive lost data while offline after reconnection. But we have an event to notify you on reconnections passing the latest record received so you can call a method to verify and get the missing data." What method or event I must to call, to keep track data state? Thanks.

No way to remove a listener

It seems there is no way to remove a listener?

If I understand correctly, events are send only to those clients which are listening for a particular event type? So if you want to stop listening to some event type, this is not possible at the moment?

Question and suggestion on allowRead() / allowWrite()

I have a question and a suggestion on the access management methods.

Question:

If all clients connect to the same stream name and both allowRead() and allowWrite() are set to true, will this cause the server to send all messages to all clients, or does it only send those messages a client has explicitly subscribed to using on(eventName)?

For instance, if I build a chat where the chat rooms are differentiated by using different eventNames, will then clients only receive messages sent to the room they've registered via on(eventName = roomName)? I know that the event handler will only be called in this case, but does this also mean that no messages are sent over the wire if the eventName doesn't match the event name in on()?

In Arunoda's stream package, I had to explicitly care for subscriptions in this case.

Suggestion:

I noticed that the server won't receive any events if allowWrite() is set to false. This is a difference to Arunoda's stream package, so would like to suggest to mention this in the docs. In Arunoda's sample code for a chat room I was inspired by, he used a special event to track on the server side if a user entered a chat room. The server was able to intercept this event even if permissions.write was disabled for the clients. Once I switched to Streamer and allowWrite, this didn't work anymore, so I will probable add a second allow-Method specifically for this event.

'stream-chat' ReferenceError: _ is not defined

Hello
I got this error after add the package to my project

Version
Meteor 1.8.1
rocketchat:[email protected]

I20210225-16:41:52.222(7)? Exception while invoking method 'stream-chat' ReferenceError: _ is not defined
I20210225-16:41:52.222(7)?     at changedPayload (packages/rocketchat:streamer/server/server.js:16:2)
I20210225-16:41:52.222(7)?     at Streamer._emit (packages/rocketchat:streamer/server/server.js:386:15)
I20210225-16:41:52.222(7)?     at MethodInvocation.method.(anonymous function) (packages/rocketchat:streamer/server/server.js:365:12)
I20210225-16:41:52.223(7)?     at MethodInvocation.methodMap.(anonymous function) (packages/montiapm:agent/lib/hijack/wrap_session.js:161:30)
I20210225-16:41:52.223(7)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
I20210225-16:41:52.223(7)?     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20210225-16:41:52.223(7)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20210225-16:41:52.223(7)?     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20210225-16:41:52.223(7)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20210225-16:41:52.223(7)?     at Promise (packages/ddp-server/livedata_server.js:715:46)
I20210225-16:41:52.233(7)?     at new Promise (<anonymous>)
I20210225-16:41:52.233(7)?     at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20210225-16:41:52.234(7)?     at packages/montiapm:agent/lib/hijack/wrap_session.js:52:38
I20210225-16:41:52.234(7)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20210225-16:41:52.234(7)?     at Session.sessionProto.protocol_handlers.method (packages/montiapm:agent/lib/hijack/wrap_session.js:51:44)
I20210225-16:41:52.234(7)?     at packages/ddp-server/livedata_server.js:559:43

Android / IOS Support

How can we use these stream events over the native android/ios client apps?

For Meteor I'm using native DDP android.

How detect if a client disconnected?

First of all, thanks for that great replacement for meteorhacks:streams. It took me only minutes to make the switch. However, I am missing one feature that was available in the streams package: To define a function that is called when the connection to the client is lost. In streams, this was possible using this.onDisconnect in an on() event handler.

Feature request: allowRead to unlogged users only

Currently, code only allows all / none / logged / a run-once callback. We have a use case where some messages (specifically: retry logging in) need to be sent only to not-logged-in users.

Of course, we can work around it in client code by allowing all and filtering the action resulting from the event, but it would be cleaner not to have to do it by not even receiving the message.

Unsure how to subscribe to a publish per user

I would simply like to keep the normal subscribe/publish, but just to send messages from publish function to a particular client which is subscribing (instead of keeping the state on the server for publish).

From looking at this package, I am unsure how to do so that each client would have its own set of messages being generated and coming from server. It seems this is more suitable when multiple clients share a set of messages. But how could I do it so that each client (or subscription) has its own set of messages, no other client can see?

Does it work with multiple instances?

Earlier I was using arunoda:cluster which has an sync method that I was using for arunoda:streams.

const streamer = new Meteor.Streamer('chat'); Meteor.Cluster.sync(streamer);

Now that I switched to rocketchat:streamer How will I sync these?

Cannot use audit-argument-checks with this package

When using the Meteor Core package, there is an intermittent error due to the fact that the options passed to the subscription are not checked.

Meteor.publish(this.subscriptionName, function(eventName, options) {

Expected Behaviour
A useful check should be performed to allow use of audit-argument-checks.

This is relating to an issue raised in my dependent project Meteor Video Chat: elmarti/meteor-video-chat#74

How to communicate between servers

Hi,
I liked this package but couldn't understand how to make a connection between two seperate meteor server. Currently, they are using the same database and one of them writes new data(realtime data from IoT devices) and another publishes the db to UI. So I need both server-server and server-client connection at the same time. Also, all the servers are clustered, maybe a special configuration is needed too.

Please enlighten me!
Thanks.

streaming(brodcasting audio )

Is it possible to broadcast audio with meteor-streamer ? like an admin account talking to his microphone and the connected clients hearing him ?

Thanks
Tom

Not working in Edge

The Websockets request appears to be returning a 101 code, which I assume means that it is using the HTTP fallback, which I assume is causing the streams to not work. I'm going to look deeper into this issue and see if I can provide more insight.

Can one create an MMO game in meteor with this?

  1. Can one create an MMO html5 game in meteor with this? For example to update the x and y coordinates, game state etc.

  2. I do not see a broadcast emitting function to send a broadcast message to all connected clients, also is there a way to see whether the user has joined and left?

  3. Can we set up private rooms and only members of those rooms will receive updated game messages , and we can have multiple private rooms?

  4. Is there any way to connect this to redis-oplog or redis (or is there no benefit of that regardless)?

I like that this package works with load balanced horizontally scaled servers.

Is this all possible with meteor-streamer. Thanks!

chat example , not getting text streamed to clients

HI a newbie, trying to use the example in the package to send chat texts to connected clients. Running meteor 1.5.2 . I see the text field to enter the text, but once I type a message, i don't see message showing up on other clients and no error on js console .

Thanks , Tom

body.html file :

{{#each messages}}
{{#if user}} {{user}}
{{/if}} {{text}}
{{/each}}

boby.js

Meteor.startup( function() {
//setup rocket:streamer for chat
const streamer = new Meteor.Streamer('chat');
const messages = new Mongo.Collection(null);
window.sendMessage = function(text) {
streamer.emit('message', {
type: 'user',
user: Meteor.user() ? Meteor.user().username : 'anonymous',
text: text
});
messages.insert({
type: 'self',
text: text
});
};
streamer.on('message', function(message) {
messages.insert(message);
});

server.js

Meteor.startup(() => {
const streamer = new Meteor.Streamer('chat');
// code to run on server at startup
streamer.allowRead('all');
streamer.allowWrite('all');

==========
.top-bar {
padding: 10px 5px;
border-bottom: 1px solid #ddd;
}
.messages {
background-color: #f1f1f1;
flex-grow: 1;
padding: 10px 5px;
}
.message {
display: inline-block;
border-radius: 15px;
color: white;
padding: 5px 10px;
min-width: 200px;
}
.message-line.user .message {
background-color: #7979EF;
}
.message-line.self {
text-align: right;
}
.message-line.self .message {
background-color: #c3c3c3;
}
input {
line-height: 1em;
font-size: 1.2em;
padding: 10px 15px;
border: 1px solid #ddd;
border-width: 1px 0 0 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.