colyseus / colyseus-haxe

⚔ Colyseus Multiplayer SDK for Haxe
https://docs.colyseus.io/getting-started/haxe-client/
MIT License
75 stars 16 forks source link

Storage: use user's path to store user data (only relevant on native builds) #62

Open endel opened 6 months ago

endel commented 6 months ago

I'm documenting this in case anybody needs this in the future. PRs are very welcome!


When building for native targets, our Storage class currently stores user data (the auth token) in the current folder, which can lead to file permission issues.

Chris from OpenFL (@Dimensionscape) has pointed the right direction on how OpenFL solved this (thank you Chris!), by using the user's path:

Please take a look at https://github.com/openfl/openfl/blob/develop/src/openfl/net/SharedObject.hx if you'd like to see how we addressed this.

We use a location dubbed the applicationStorageDirectory which is resolved through our native extension in Lime https://github.com/openfl/lime/blob/bb3b31b08d75c0b9aa2dc1f3ab5f4539737f4d57/src/lime/system/System.hx#L419