Socket.io v1.x with native platform

Hello,

i’m working on multiplayer game with socket.io/nodejs server and cocos2d-js 3.6.1 as client.
Everything works with socket.io v0.9x but not with 1.x (400 transport error).

I have manually changed socket.io.min.js in cocos2d html5 and server to 1.x. It works. But it does not work for native version.

I see some post talking about socket.io v0.9x and v1x support with cocos2d-x. Do you know how to support socket.io 1.x on native platform with cocos2djs ?

Thanks

In fact, the socket io native implementation need to be upgraded, sorry for the inconvenient. It’s scheduled to v3.8:
https://github.com/cocos2d/cocos2d-x/issues/11739

The current implementation is here: https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/network/SocketIO.cpp

1 Like

Thank you @pandamicro

@pandamicro

Has this fixed?
Thanks

With 3.8, I could connect but, emit didnt work. Help please… . @pandamicro

On Android… HTML worked fine.

@thomasjab Did you managed to solve socket.io issue? Thanks

Reporting:

Continuing the discussion from Socket.IO Extention Update - 1.x working with 0.9.x backwards compat:

I switched to websocket. I don’t know if native platform have been updated

1 Like

Cross posted from Socket.IO Extention Update - 1.x working with 0.9.x backwards compat , let’s keep the discussion in this thread

@StudioAMK Is this only happening on Android, or can you test the same code on Win32 or OSX? If the issue is only on Android, are you enabling permissions for local storage and network access in your Android Manifest XML file?

This could be the cause of both warnings about storage and http classes, as well as the reason that the code works without error but no network packets are sent.

1 Like

@hannon235

Edit: Just tested on Win32. Same issue. Incoming ok. Outgoing failed.

what I got form AndroidManifest.xml (looks ok?):

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>  
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>  
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>  
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>  

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Beside that, I’ve compiled and tested with Cocos2d-X JS test project yesterday. The same issue.

Could this be because of NDK / SDK / JDK versions?

Source Codes Added There:

fixed in https://github.com/cocos2d/cocos2d-x/pull/13953

1 Like

If we use socket.io.js from socket.io, will it work in android and ios?