[Updated w/Post]Using C2 WebSocket Plugin + WS?

Discussion and feedback on Construct 2

Post » Sat Dec 07, 2013 9:54 pm

[QUOTE=Index]Socket.IO brings in extra functionality. It uses websockets but also has things like rooms(channels) and fallback policies*. A reason to not use Websockets is that if you don't need that functionality or you want to custom add what you want.

*Fallback policies are presented when a client fails to utilize websockets. This can allow non-websocket accepting browsers and mobile devices to still have a websocket-like connection.
Note: Preview mode when using Socket.IO seems to always use a non-websocket mode.[/QUOTE] I was going to use Socket.IO, but the error I posted above, debug - destroying non-socket.io upgrade, prevented me from testing it out because the server flat out refused to connect.

If you can get a Socket.IO server and C2 to cooperate that would be great. I can't. XD

Otherwise, I'm using WebSockets, mostly because it's the only vanilla support C2 has for creating multiplayer.

On the server side, though, I've taken a peek at Photon. I'm just not sure which would be better for a beginner with $0 money to spend, heh.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Sat Dec 07, 2013 10:07 pm

Add

io.disable('destroy upgrade');

[io is related to the "require('socket.io')" statement]Index2013-12-07 22:08:08
B
73
S
10
G
6
Posts: 105
Reputation: 7,577

Post » Sun Dec 08, 2013 3:31 am

Thanks, @Index. :)

So does that just mean that Socket.IO cuts connections by default unless the client is also using Socket.IO?
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Sun Dec 08, 2013 4:28 am

I suppose so. Which makes me wonder why previewing makes it think you're not using Socket.IO.

B
73
S
10
G
6
Posts: 105
Reputation: 7,577

Post » Thu Dec 12, 2013 5:50 am

Bringing this back up, it appears that Socket.IO flat out refuses anything Construct 2 can throw at it.

I've made the most simplistic server I could possibly manage, even disabling the retarded "destroy upgrade:"

var io = require('socket.io').listen(8000);

io.configure(function(){io.disable('destroy upgrade'); console.log('configured');});

io.sockets.on('connection', function (ioC) {
     console.log('connection opened');
});


This successfully starts the server, and the string "configured" is logged as expected. However, no connection is made. At all.

I've taken a look at dozens of user snippets and there are no diversions from other code. It's just boggling my mind.

With my client I can connect perfectly fine to the WS module server I set up, sending packets like mad, but Socket.IO just fails.

Any help? Suggestions? I feel only like I've wasted two hours trying to get it to work, with 0 results.

@Index, @Ashley
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,826

Post » Thu Dec 12, 2013 1:17 pm

If you have decided to definitely go with socket.io on the server side, you should also use socket.io on the client side. I guess they implement some kind of protocol on top of websockets so you'll need both ends to be speaking the same dialect.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Thu Dec 12, 2013 5:14 pm

Ashley is right- you need to use the Socket.IO Construct 2 plugin to connect to a Socket.IO server. - I've never used that Websocket plugin *shrugs*

I recommend this one : http://www.scirra.com/forum/socketio-mod_topic63284.html

I'm also going to try learning the Javascript Plugin SDK to try updating (recreating) the PubNub Plugin. (Pubnub => http://www.pubnub.com/)

Good Luck with your Game.


My Socket.IO Settings
[code]
io.enable('browser client minification'); // send minified client
io.enable('browser client etag');          // apply etag caching logic based on version number
io.enable('browser client gzip');          // gzip the file
io.set('log level', 3);                    // ---0 = Errors --- 1 = Warn --- 2 = Info --- 3 = Debug---
io.disable('destroy upgrade');

io.set('transports', [
    'websocket'
// // WARNING // // USE ONLY WEBSOCKETS WHEN USING SSL (WSS) SECURE // // WARNING // // USE ONLY WEBSOCKETS WHEN USING SSL (WSS) SECURE // //
// , 'flashsocket'
// , 'htmlfile'
// , 'xhr-polling'
// , 'jsonp-polling'
]);
[/code]

Note: I wrote that warning some time ago. Someone had mentioned that a secure connection was faulty under other protocols other than a true websocket connection. This may no longer be true, should check up on it if you're curious.
B
73
S
10
G
6
Posts: 105
Reputation: 7,577

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests