Socket.IO Extention Update - 1.x working with 0.9.x backwards compat

@josempan I will test with localstorage and will let you know. Plz share us if you find your solution as well… cheers

Dear @hannon235

If your time allows, please kindly help me look into the issue…

Thanks!

@josempan confirmed not working. just tested.

@StudioAMK @josempan I tested this with a clean install of cocos2d-x 3.8, it works with socket.io v0.9.* but fails with socket.io v1.3.*

Looks like somebody has already opened an issue on github for it: https://github.com/cocos2d/cocos2d-x/issues/13929

I am cloning the most recent cocos2d-x repo and will debug it when I have time, it looks like a bug was introduced somewhere between my commits from April and the 3.8 release

1 Like

@hannon235

Thanks… so much! I thought it was my fault…

What an unlucky newb I am…!! ha ha :smiley:

cc.sys.localStorage is also broken…

Could you please kindly double check again?

the socket.io extension can be fixed by updating line 233 of SocketIO.cpp from _endpointseperator = “:” to _endpointseperator = “”

I’ve fixed this in PR #13953 on github if you would like to see the code:

sorry, I don’t know what’s going on with the storage, I wouldn’t know where to start

1 Like

About the localStorage, I keep getting that warning, but somehow is writing the file (maybe in the default internal storage). I’ve get this working with a change on the code, this workaround was only necessary after testing on Android, my last code didn’t worked but with these changes is working ok:

var userData = null;
var userDataKey = "UserData";
var ls = cc.sys.localStorage;

userData = ls.getItem(userDataKey);

if (userData == null)
{
    cc.log("No saved file... Saving new one");
    var userDataValue = JSON.stringify(LevelInfo)
    cc.sys.localStorage.setItem(userDataKey, userDataValue);
}

I don’t know why this code works and the last one doesn’t. Is weird because the last one was working ok on web and iOS, but not in Android.

What version of Socket.io does the stock Cocos2d-x 3.7.1-3.8 support? I’m trying to figure out why my socket code isn’t working, thanks!

versions up to 3.8 support v0.9.x, version 3.8.1 supports socket.io 1.x due to a bug in 3.8

You saved me! This was driving me crazy, but finally applied your patch and I can emit on the socket to my server.

I can get return string after emitting to server.
My own server can get message name, but can not get any data…
How can I fix it?

@hannon235… please check… another bug :slight_smile:

Continuing the discussion from SocketIO - Connect failed after Disconnected: