socket.io and c2's plugin behavior

0 favourites
  • 10 posts
From the Asset Store
Shark.io
$49 USD
Shark.io in the sea full of killer sharks, Sunday of life is the game. Who knows what is happening under the sea?
  • Hi,

    I have been messing with Zacko's socket.io plugin for a bit, learning javascript as I go.

    I have got an environment setup where I can get two clients to handshake.

    But an interesting bug / limitation has come to my notice.

    Download this:

    dl.dropbox.com/u/24356445/socketiostuff.zip

    Unzip

    execute runserver.bat. This runs the server. I have included the socket.io module in the same folder. If you have issues setting this up, look at Zacko's page about installing nodejs and socketio.

    now openup the socketiostuff.caproj, this is a simple two layout project, where if you click, you move to layout two, which initializes the "handshaking" (connects to localhost), if you click again, you disconnect from the server.

    What is interesting is if you disconnect, it seems to be destroying the plugin instance?

    If you disconnect-> go to layout 1 -> and look into your javascript console for errors, you see a call to OnDisconnect (from the socket.io plugin) on a null object. So basically the application crashes.

    I noticed this first when trying to have two clients on localhost, while trying to test my handshaking stuff. The examples we have seen on socket.io do not cover disconnect. (but it is of course essential that you disconnect from the server when needed)

    I will dig into the socket.io code later, but just wanted everyone to know this happens.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • btw while testing I removed the comment on (runtime.js of the socket.io plugin):

    //socket = new io.Socket(host,{port:port,transports:["websocket","flashsocket","xhr-multipart","xhr-polling","json-polling"]});;

    But that should not make a diff, as it gets reassigned on the next instruction. And I can verify this happens even with the original code.

  • I have a fix for this (runtim.js of socket.io plugin)

    change:

    socket = io.connect('http://' + host + ':' + port);

    to:

    socket = io.connect('http://' + host + ':' + port, {'force new connection': true});

    The socket does not connect when you reattempt a connection while switching layouts. I guess the socket.io plugin was designed to have one connection throughout your game. I don't know the side effects of this change, but if you guys think this could cause problems, let me know.

  • I can't pronounce your name, but I love you. Thanks for the fix.

  • This is probably a bug in the author's code. You might want to try and contact them for fixes/updates.

  • This is probably a bug in the author's code. You might want to try and contact them for fixes/updates.

    He hasn't been active for 142 Days. I'm not sure he's coming back.

  • In that case, I think Ashley it should be safe for you to make that change, its been stable for me, and I can't see it causing side-effects.

  • bhavanvaishnav

    Sorry, it's not Ashley's job to modify third party plugins - let him use his time to make C2 even better.

    Why not have a go at making the mods yourself and re-release the plugin? (People like Taurian will bless you even more :)

  • Re-releasing a plugin as a mod, the "mod" being a bug fix, does not sound right to me.

  • bhavanvaishnav Is it possible to re upload the latest working version you have made of this plugin? I have some things I would like to do with it but would rather start with your version as it seems to be one of the most up to date versions of the plugin.

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