Migration guide from api-js 1.2.0 to 1.7.17

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

Post Reply
midaV
Posts: 2
Joined: 25 Feb 2021, 16:27

Migration guide from api-js 1.2.0 to 1.7.17

Post by midaV »

Can I find somewhere a migration guide to update the library on the frontend from version 1.2.0 to 1.7.17?
I try just to update lib to new version but there are so many changes... I spent the whole day making changes, but I'm still not done. :(
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Migration guide from api-js 1.2.0 to 1.7.17

Post by Lapo »

Hi,
no we don't have such guide. The two API are indeed pretty different as the original JSON-based API was a simplified version of the API we have for other languages such as C#, Java, Objective-C etc.

I think the best approach is to rewrite the application starting from the original code and rebuilding it using the new API, via the reference docs and examples.
http://docs2x.smartfoxserver.com/api-docs/jsdoc/client/
https://www.smartfoxserver.com/download#p=examples

If there's any question regarding the API let us know
Lapo
--
gotoAndPlay()
...addicted to flash games
midaV
Posts: 2
Joined: 25 Feb 2021, 16:27

Re: Migration guide from api-js 1.2.0 to 1.7.17

Post by midaV »

Unfortunately, the application I'm developing is not so easy to rewrite...
Thank you for your reply.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Migration guide from api-js 1.2.0 to 1.7.17

Post by Lapo »

I don't think this should affect the logic of your application that much. The legacy Javascript API and the new JS API differ mainly in how data is transported between client and server, using different objects to carry such data.

In the old API it was done through native JS data structures, in the new API it is done via the SFSObject/SFSArray classes. Other than that the API work pretty much in the same way. You still add custom event listeners for server events and send requests in the same way.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply