socket.io and c2's plugin behavior

For developers using the Construct 2 Javascript SDK

Post » Fri Jun 01, 2012 9:50 pm

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:
http://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.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Fri Jun 01, 2012 10:16 pm

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.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Sat Jun 02, 2012 8:46 am

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.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Sun Jun 10, 2012 11:53 pm

I can't pronounce your name, but I love you. Thanks for the fix.
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,637

Post » Mon Jun 11, 2012 2:28 pm

This is probably a bug in the author's code. You might want to try and contact them for fixes/updates.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Tue Jun 12, 2012 1:09 am

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

He hasn't been active for 142 Days. I'm not sure he's coming back.
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,637

Post » Sun Jun 17, 2012 8:00 am

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.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Sun Jun 17, 2012 10:13 am

@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 :)Velojet2012-06-17 10:14:24
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sun Jun 17, 2012 5:13 pm

Re-releasing a plugin as a mod, the "mod" being a bug fix, does not sound right to me.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Fri Aug 31, 2012 3:01 pm

@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.
B
16
S
2
G
4
Posts: 67
Reputation: 3,295

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests