[demo] socket.io&http server in construct2[update]

Post your completed addons to share with the community

Post » Fri Dec 07, 2012 8:55 pm

---------
Updated demo here!

Server code:



Server looks like this. Click "engage server" to start listening for connections. After that, click on "Deploy client".



Client looks like this. You can send a message event to server. Client also receives windowx, windowy position of the server window.



If you go to localhost:54321/something, http server will response:



Cheers!

------------

I just started to work on this, but this is so great that i had to share:




Socket.io (and a http server) written in Construct 2. Download demo here.

Run it, press a button, and voila. You've got yourself a semi-functional server written in C2. When you request a "localhost:54321", it will respond with "Welcome to socket.io"

It cannot accept any socket connections yet, but hopefully in a few hours it will!



Cheers!JohnnySheffield2012-12-11 21:08:00
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Fri Dec 07, 2012 11:11 pm

@JohnnySheffield

Could the export file not to be "*.exe" file, only *.js files , so that it could be upload to cloud server like heroku?

BTW, these cloud enviorment might not allow render feature since they don't have DOM.rexrainbow2012-12-07 23:28:37
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Fri Dec 07, 2012 11:31 pm

With just a plugin, and directly from the C2, don't think so.

But with a custom-made C2 app that is utilizing "write to file" plugin, and has duplicated construct GUI and way of writing code (Constructception?) it's possible, but time consuming.

OR, create a plugin that creates a function(or some object containing your server code) in C2 runtime, and, when you export it unminified and start the app, plugin provides access to that object's containing code and exports it to you as a .js file.

I believe it's possible, but the solution would be hackish/impossible without some cooperation with scirra team.

But the main problem currently for me with combining node-webkit, node.js and Construct 2 is how to transfer the asynchronous I/O nature of node.js to construct successfully and tidy with it's bunch of callbacks, and still preserve the simplicity of coding in construct.
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Fri Dec 07, 2012 11:39 pm

They won't allow you, cause they don't have access to it.

Beauty of node-webkit is in the simultaneous access to DOM and Node.js enviroment and possibility to "mix" the code


When you have node.js server in the cloud, most simple would be using express module, or even node-static to serve your exported project.


Fun thing with node-webkit and socket.io is in possibility to utilize node2node-socket.io module and then create a game that doesen't have a central server, but exists when nodes connect to eachother and create worlds and share data. Each client would be at the same time a server, and each server could take care of it's own data and security, but also accept orders form other servers on what to do with data. Let's call it "cloud-gaming".

So you actually don't need a .js file from construct. if you need a .js file, open up a notepad++ and write it!

We just need smartly designed, simple node-to-node plugin to make direct connections between clients/servers. and possibility for a wierd, but fun way to create multiplayer games in C2.
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Sat Dec 08, 2012 12:25 am

It makes me wonder if is possible to make a local server
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Sat Dec 08, 2012 12:32 am

@Johannesalfa

run the demo, point your browser to "localhost:54321" and see what happens.

It's a socket.io/http local server running on port 54321. :D

JohnnySheffield2012-12-08 00:32:59
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Sat Dec 08, 2012 1:00 am

wow magic!





Joannesalfa2012-12-08 01:00:42
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Sat Dec 08, 2012 1:27 am

juicy things are afoot...
B
52
S
17
G
15
Posts: 1,029
Reputation: 26,339

Post » Tue Dec 11, 2012 9:09 pm

Updated server a little bit, check the first post for demo and screenshots!

Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Tue Dec 11, 2012 10:33 pm

@JohnnySheffield you are awesome!
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests