How do I share data between apps?

Get help using Construct 2

Post » Fri Aug 08, 2014 5:44 pm

I have created two separate apps. They both use NodeWebKit to create a .exe for use on Windows computers.

I would like to be able to share data between the two apps. Instead of combining the two apps I think it would be easier to simply output data from one and read it with the other...

I would also like it to be fast enough that I can create triggers in one app and have them picked up in the other app.

App 1: press button to set (webstorage?) variable to 0 or 1
App 2: while variable is 0 do A, while variable is 1 do B

Is there a way to do this? Through JSON or AJAX or Webstorage or something? I need to pass a trigger and a number but if I can pass one I can figure out the other...

Both apps are running at the same time on the same computer... Is Webstorage Local or Session available as the same thing between both apps or does each app create its own instance and you can't share the data?

Thanks!
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Tue Aug 12, 2014 10:29 am

Maybe it's somehow possible to do with file chooser and dictionary, download the json string of what you want from first app to your device, then with file chooser you open it in other app, i don't know if it's gonna work and i didn't try this.
B
22
S
9
G
7
Posts: 421
Reputation: 6,543

Post » Tue Aug 12, 2014 1:17 pm

R0J0hound suggested using the clipboard in a different thread. Maybe you could try that depending what data you need to share.

Edit: I just noticed this is an older version of your other thread. I guess you have it sorted now.
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Tue Aug 12, 2014 3:59 pm

Export your first project for nw, any others would be exported as html5 (this is because you can't run nw.exe twice)
From your first project you are able to open a new window (Assuming you know a little js)
From the new window you can communicate back to the opening window with window.opener
I've been working on an addon that does this and a fair bit more, it's not ready for public release but if this is a paid job give me a PM and I could have something for you the same day most likley.
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Wed Aug 13, 2014 12:27 am

I am running two NW.exe one called ColorPage.exe and one called ButtonPage.exe

Using a suggestion from R0J0hound I have managed to get this to work using the Clipboard.

You may be correct in that the websocket/socket.io/node.js issues I am having are because I am running two NW apps at the same time but I have a node.js programmer working with me now to figure that all out.
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Wed Aug 13, 2014 3:12 am

Sorry I misunderstood, I thought you wanted to run two games from the same nodewebkit export, in which case you can indeed mix two games but only one can be exported for nw 8-)
Image
This allows for two way communication without websockets or multiplayer, but it's slow...
If you aren't trying to sync anything frame rate dependent I guess it doesn't matter though
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Wed Aug 13, 2014 9:44 pm

Interesting... good to know for the future! For the project I am on I am only trying to send a trigger message which can delay even up to a full 1 second and the user experience won't suffer. Thanks for giving me something new to look into after this project is complete! (if it ever completes... ugh)
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Wed Aug 13, 2014 9:50 pm

Did you try saving and loading simple text files?
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Wed Aug 13, 2014 9:57 pm

I wanted to avoid using anything that specifically wrote files because of how long this app is going to be running. I don't know if the clipboard uses a drive based cache or not. This app will potentially run 24/7 for ... years? Not sure what they will do with it once I hand it off. If I can keep these messages from stressing the hard drive more than just normal operation that would be ideal. I am still working on the websocket solution as this would give me incredible flexibility to do all kinds of interfacing and communication with lots of stuff outside of C2 and my apps. The use of the clipboard is a great temporary fix for this, and will likely get me through my demo with flying colors, but getting the websocket working is really the ideal situation.
B
10
S
4
G
2
Posts: 133
Reputation: 2,667


Return to How do I....?

Who is online

Users browsing this forum: babymumu and 7 guests