colyseus / colyseus.js

⚔ Colyseus Multiplayer SDK for JavaScript/TypeScript
https://docs.colyseus.io/getting-started/javascript-client/
MIT License
407 stars 105 forks source link

[Bug]: Cocos Creator 2.4.6 JSB-Builtin does not support many new syntax in iOS environment #128

Closed jadehare closed 1 year ago

jadehare commented 1 year ago

version:0.15.11

The issues currently identified are all in the iOS environment.

The object created by calling document.createElementNS in new URL does not have a prototype, resulting in an error. ([https://github.com/cocos-creator-packages/jsb-adapter/blob/410a9ed25c5ad91c064682c8ed0f2093a5dd4ef6/builtin/Blob.js#L93C56-L93C56])

There is no fetch method in colyseus.js:140.

There is no FormData type.

I have rewritten the parameter acquisition for the new URL issue, and found a solution to the FormData issue in another issue. I currently have no idea how to solve the fetch issue, and hope to be informed of a solution. I also hope to have a more elegant solution to other issues. I have not verified if other versions of Cocos have the same issues, but given that this part of the code does not appear to have been updated, I suspect that they may have the same issues.

endel commented 1 year ago

Hi @jadehare,

About fetch and FormData:

About URL not having a prototype:

const client = new Colyseus.Client({
    hostname: "server-1.your-game.io",
    secure: true /* for wss / https */
});

Let me know if you have any other issues on iOS. Cheers

jadehare commented 1 year ago

Thanks a lot, this JS file is really working for me.

I'm sorry, I made a mistake. It's not that createElementNS doesn't have a "prototype", but rather that the return object doesn't have "protocols" :( However, the result is similar, so it doesn't affect me. I apologize for providing incorrect information.

Also, I couldn't find the JS file for Cocos Creator in the document, or the zip file, or other branches. For versions before 3.0, I can only manually add the JS file. I hope it can be added to the document of future versions, so that I can replace it directly without bothering you.