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

0 favourites
From the Asset Store
Demo Game Multiplayer Online with member registration system
  • ---------

    Updated demo here!

    Server code:

    <img src="http://i.imgur.com/cdqJC.png" border="0">

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

    <img src="http://i.imgur.com/KQ6z7.png" border="0">

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

    <img src="http://i.imgur.com/ZwhIo.png" border="0">

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

    <img src="http://i.imgur.com/CKiWT.png" border="0">



    I just started to work on this, but this is so <img src="smileys/smiley35.gif" border="0" align="middle"> great that i had to share:

    <img src="http://i.imgur.com/Vumrq.png" border="0">

    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!


  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • It makes me wonder if is possible to make a local server

  • 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

  • wow magic!

    <img src="http://i.imgur.com/0wGfI.png" border="0" />

    <img src="http://i.imgur.com/Ly2kA.png" border="0" />

  • juicy things are afoot...

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


  • JohnnySheffield you are awesome!

  • Got some questions in inbox regarding tcp, udp and socket.io, so i'll just paste the response here, maybe someone will find it useful:


    Yes, indeed it is using tcp for transport, and no, there is no indication that it will support udp (Some security issues with browsers, as it seems, there was some talk about it on socket.io mailing list).

    I don't see that as a big issue, advantages of socket.io are multiple (main advantage is that you can use them in a browser, as for udp there's no client library or other possibility to get it in browser), and in my opinion, this is the best starting position to write a some sort of browser/node-webkit multiplayer game. UDP is something that is really useful and has some advantages (speed) but i believe it's something you should add in a "second stage" (whatever that means)of development, and build it with writing actual code - not inside construct 2.

    Also, there's a "volatile" method in server-side of socket.io that behaves somewhat similar to udp (it won't get delivered if the client isn't ready to recieve it.) so that should help to speed things up if speed of websockets (?!) is an issue!

    But why not, i'll try to make a simple udp plugin, if node-webkit supports it! (but not so soon!)



    Also, on the side-note, this whole thing with writing a server in construct 2 is currently just an experiment, we must think "outside of the box" how to set-up whole "multiplayer" thing with node-webkit if we want to make some feasible solutions. It's not impossible, hell, last week i never really thought that it will be possible to write any kind of server in construct 2, and that changed, so who knows, we'll see what future brings!

  • <img src="http://captionsearch.com/pix/p9x33yj194.jpg" border="0" />

  • <img src="http://captionsearch.com/pix/p9x33yj194.jpg" border="0" />

    <img src="http://www.troll.me/images2/grammar-correction-guy/-youre.jpg" border="0" />

  • This is amazing :) it's much more accessible than the others we had before.

  • R116 support Linux exporter, does it mean we could create node.js server by c2 which running at Linux environment like linode?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)