i have this simple code in typescript
var sioclient = io.connect(“localhost:52300” );
io its not recognized
On server i have endless connection attempts
i have this simple code in typescript
var sioclient = io.connect(“localhost:52300” );
io its not recognized
On server i have endless connection attempts
It was not recognized by VSCode intellisense.
Cocos Creator native engine (not web) already has socket io.
A good read:
https://docs.cocos2d-x.org/creator/manual/en/scripting/network.html
Yes something was wrong with the definitions.
But why the client is connecting múltiple times?
Plz check example project. They have a working codes from where you can learm from.
I already did that. I used the code from the example.
I’ve no time to play with 2.1.2 yet. It worked fine in 2.1.0, for sure.
But how are you implementing it?
did you download socket.io as plugin or did yoou use the socket.io from cocos itself?
the documentations says the socket.io is not integrated but looks like that in latest version it is packaged with cocos
is NewClass
instantiated multiple times? Generally, you should place your socket code inside a singleton. Also, log the disconnect
message, and make sure the client isn’t simply connecting->disconnecting->connecting->reconnecting…
I have a node called TestNode with the script Test.ts
the server detects when a player connectes and disconnects. I tested with ue4 using socket.io plugin and it works
now when i play the game from cocos i get this
have you debugged what is causing the disconnect?
As i said. With the ue4 socket client it works fine. So something happens with the socket.io client in cocos.
What is socketio version at server side?
If you are using 2.x then try with 1.x, it should work.
ya, try with 1.7.3.
It wont make much difference (AFAIK)
Have you tried to log errors on both client and server side? Generally socket.io should have some error before it decides to just disconnect…
Sorry for not having a quick cut answer, I program with cocos2d-x in C++ so only have generalized ways to help.
Can you make sure the connection is being upgraded from http to websocket? Did you make sure to include transports: [websockets] in the connection… (client side)