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

Grain events #1629

Open
synchrone opened this issue Mar 4, 2016 · 6 comments
Open

Grain events #1629

synchrone opened this issue Mar 4, 2016 · 6 comments

Comments

@synchrone
Copy link

Sometimes apps would like to get notified about user actions done in sandstorm.
For example, user changing the grain name.

I would like to propose a way for web apps in grains to register for updates:

window.parent.postMessage({subscribeToEvents:['grainNameUpdate']}, "*");

and then get notified when the user changes it:

window.addEventListener("message", function(e) {
    if(e.data.sandstormEventName == 'grainNameUpdate'){
         var newName = e.data.grainName;
         // to what the app needs
    }
});

The same mechanism can be used to have the apps subscribe for other user-generated web events, like: app permissions changed, access token revoked, user name changed, grain list collapsed, etc.

@synchrone
Copy link
Author

Relates to synchrone/sandstorm-radicale#14

@kentonv
Copy link
Member

kentonv commented Mar 5, 2016

Seems reasonable. Note that there's a funny property of grain titles right now in that each person to whom the grain is shared can potentially set their own title which only they see. See #1087. So this is kind of unexpectedly complicated.

@mitar
Copy link
Contributor

mitar commented Apr 17, 2016

Hm, it might be that app misses such an event. It would be great if server-side could ask Sandstorm for current state if it feels it is behind.

Furthermore, I think it would be better if events would go to the server-side, not client-side. Client-side is still not trusted.

@synchrone
Copy link
Author

Currently the only way an app can "ask" about anything is via window.parent.postMessage and get a response via message listeners, checking the same "code" was returned.

Server-side communication is currently harder to handle. App devs need to use captn-proto bindings to their language, or engage in exec()ing custom-built binaries due to lack thereof.

This whole grain communication kind of needs to be rethinked, cause currently it feels we're trying to re-purpose a mechanism not intended for doing this.

@mitar
Copy link
Contributor

mitar commented Apr 18, 2016

At least for Meteor apps: maybe Meteor app could just create a server-side DDP connection to some Sandstorm endpoint and get those events?

@paulproteus
Copy link
Collaborator

Hi all,

Another way to think about this is that the UiView capnproto interface could grow methods that Sandstorm would call to notify it of changes. Then sandstorm-http-bridge would be responsible for passing those into apps. One way to do so is over Meteor/DDP as @mitar suggests. Another is over a HTTP POST.

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

4 participants