nbarkhina / N64Wasm

A web based N64 Emulator
https://www.neilb.net/n64wasm/
MIT License
622 stars 132 forks source link

Possible enhancements for self-hosted scenario? #1

Open GitBOUF opened 3 years ago

GitBOUF commented 3 years ago

Hi!

When I found your code, I was happy to see it is still actively being developed! I've managed to build it on a headless Ubuntu 20.04 machine and access it from a browser on my network using nginx. It worked really great!

While testing it in a self-hosted scenario, I stumbled upon some missing features that I think would be absolutely great for anyone wanting to self-host your emulator:

  1. Store game saves on server-side disk and not just in the browser. I think, if I understand it well, that webassembly does not allow accessing the client disk directly, but what about writing to the server's disk? In a self-hosted scenario, all saves could be kept on the server, accessible from any browser.
  2. (More of a precision to 1) The ability for games to save directly on server's disk rather than saving "states".
  3. The ability to disable the "load from file" game in the settings. In a self-hosted scenario, I much prefer having my game library on the server and block any "file upload" feature for security reasons. Since the code already support loading a local game library, the ability to disable the upload feature would be great.
  4. Multiple controller (or keyboard) profiles for multiplayer support.

The points above could really bring the self-hosted n64 emulation to another level. With these features, I would be interested in making a docker image of your project, with your permission.

Of course, those are just suggestions. If none of them are going in the direction you had in mind for your project, feel free to close this issue :).

nbarkhina commented 3 years ago

Hi @GitBOUF

Thanks for your interest in this project. In terms of saving the SaveStates to a server rather than the browser, most of that functionality I have already built into the emulator. If you take a look at "settings.js" there is a setting called "CLOUDSAVEURL". Once you change that to a URL you will see some of the functionality in the emulator will change. You will see a "Login" button appear on main page.

The idea here is that if you have a server set up that exposes a few endpoints, the emulator already supports saving to a cloud server. I actually have server code written but I did not to upload it to GitHub because server code is a lot less universal than front end code. My server code uses a .NET Framework Backend with a Microsoft SQL Server Database. However other folks may prefer a completely different stack (Node, MongoDB, etc...) That's why it's basically up to you how you want to implement that, but the front end code is all there already. If you take a look at script.js, all you would need to do is implement these 4 endpoints -

/Login /GetSaveStates /SendStaveState /LoadStaveState

You should also be able to see what these endpoints are expecting to receive back from the server as valid responses. In terms of your suggestion for multiple controller support, that is something I am planning on implementing in the future.

Thanks

nbarkhina commented 3 years ago

@GitBOUF I went ahead and added the server code for cloud savestates into the server folder. You can check out the new Dockerfile here

https://github.com/nbarkhina/N64Wasm/tree/master/server/docker

Let me know if you have any issues.

Thanks

GitBOUF commented 3 years ago

Thank you very much! I'm currently trying to build my own server with .NET Core. I'll give a look at your server code to understand how the API should behave server-side.

Have a good day!