[POC] 3DS Websocket server demo for homebrew utilities

Discussion in '3DS - Homebrew Development and Emulators' started by TheCruel, Feb 27, 2017.

  1. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    Testers needed. This is mainly a proof of concept for developers, but I would like others to test it too so I can better refine it with more browser/system support. Let me know if you have difficulties/bugs.

    This technology can allow developers to make applications in web browsers that can interface with the 3DS console. A lot of possibilities.

    Demo: http://ws3ds.cruels.net/

    Server source: https://github.com/Cruel/websock3ds/
    Web source: https://github.com/Cruel/websock3ds/tree/gh-pages



    @MarcusD and @zaksabeast I would've pinged you guys about this in discord server, but I think some moralfag banned me.
     
    Last edited by TheCruel, Feb 27, 2017


  2. iAqua

    iAqua Shadow of Dark.

    Member
    GBAtemp Patron
    iAqua is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    2,613
    2,027
    Dec 7, 2015
    Canada
    very nice, great work!
     
  3. addi33

    addi33 GBAtemp Advanced Maniac

    Member
    1,641
    701
    Sep 12, 2016
    Gambia, The
    Isn't Pokémon Showdown a Websocket based Client or something like that?.......:creep:......
     
  4. natanelho

    natanelho GBAtemp Maniac

    Member
    1,243
    309
    Apr 25, 2015
    Tuvalu
    WOW great! can this run in background on 3ds?
     
  5. Exavold

    Exavold GBAtemp Advanced Fan

    Member
    995
    1,043
    Nov 9, 2015
    France
    That is very interesting.
     
  6. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    Not exactly, not without homemenu hacks. Currently it's up to the homebrew itself to supply code to connect to browser. This demo app should serve as an example for devs.
     
  7. umbjolt

    umbjolt Wild jolteon

    Member
    531
    137
    Sep 15, 2016
    Magnolia, Fiore
    This. is. AWESOME!!!
     
    addi33 likes this.
  8. umbjolt

    umbjolt Wild jolteon

    Member
    531
    137
    Sep 15, 2016
    Magnolia, Fiore
    BTW, @TheCruel pressing Start gives me:

    "read: No more processes
    Websocket handshake failed!"

    Using the console IP works fine :)
     
    addi33 likes this.
  9. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    Does it just keep giving that over and over or does it eventually work? Because it will occasionally fail, but should keep retrying.
     
  10. umbjolt

    umbjolt Wild jolteon

    Member
    531
    137
    Sep 15, 2016
    Magnolia, Fiore
    I left it try about 2-3 minutes but suddenly 3ds "console" stopped writing (I don't mean freeze, just it stopped printing new text), and after that, using the IP it works at first try. I've tested about 3 times. The two first times were like that. The third time, it only wrote that "error" text 4 times and stopped printing new text.
     
    TheCruel likes this.
  11. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    Thanks, that gives me a better idea of what's going on. I think I might know what it is.
     
    Last edited by TheCruel, Mar 1, 2017
    umbjolt likes this.
  12. umbjolt

    umbjolt Wild jolteon

    Member
    531
    137
    Sep 15, 2016
    Magnolia, Fiore
    Your welcome. I'm glad that helped you :)
     
  13. shutterbug2000

    shutterbug2000 Cubic NINJHAX!

    Member
    1,078
    2,085
    Oct 11, 2014
    United States
    Can this interface with other websocket-based applications? Like, say I wanted to make a 3DS client for, idk, slither.io(just as an example). Would this work for that?
     
  14. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    It currently runs as a websocket server and not a client, but yeah you could use it as a websocket client too with slight changes. I was thinking about making a agar.io client for 3ds, but have other things to do atm.
     
  15. Quantumcat

    Quantumcat Dead and alive

    Member
    9,813
    5,124
    Nov 23, 2014
    Australia
    Canberra, Australia
    If you send text/pictures does it send it to every console that has installed the app? Or is it a unique installation per console somehow?

    Edit: After seeing the code, I get it, it runs locally.

    Would there be any chance of demonstrating uploading files from the 3DS to the server, and downloading files and saving them to the console's SD card?
     
    Last edited by Quantumcat, Mar 1, 2017
  16. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    This is only communication between your browser and the 3DS, nothing more. So nothing is stored on another server or going through any other server. The 3DS console is the websocket server and the browser is connecting to it.

    My demo is hosted via github pages, so anyone can make their own too. Only problem is that it currently doesn't have SSL support. Or rather, most popular browsers reject self-signed certs over secured websocket, so I didn't bother figuring it out.
     
    Last edited by TheCruel, Mar 1, 2017
  17. Quantumcat

    Quantumcat Dead and alive

    Member
    9,813
    5,124
    Nov 23, 2014
    Australia
    Canberra, Australia
    Thanks, I was looking at the code, edited my post at the same time you replied :-)

    Another edit, I realise no download/upload is possible, because it's javascript, not PHP. Is that right?
     
  18. TheCruel
    OP

    TheCruel Developer

    Banned
    1,351
    2,882
    Dec 6, 2013
    United States
    Sure, the code is already there for transferring images. Instead of just copying it to the framebuffer, you could save it to file. Likewise simple for sending from 3DS to browser.

    At the moment, any binary data of the right size is considered an image to copy to framebuffer:
    https://github.com/Cruel/websock3ds/blob/dcdb2036acb661fe55f13aeb50f92302576fc788/src/main.c#L97

    But currently the browser client doesn't do anything with binary data sent to it since the title data the 3DS sends to it atm is a JSON string:
    https://github.com/Cruel/websock3ds/blob/aec054c3c08a02d49fb6ad2da6e2122e6f1cd4ac/js/main.js#L33

    EDIT: there are some security issues with browsers saving to disk, but it's possible you just need to add a button or something to trigger the saving. Guess it could be useful to show how to do that if anyone wants it.
     
    Last edited by TheCruel, Mar 1, 2017
  19. Quantumcat

    Quantumcat Dead and alive

    Member
    9,813
    5,124
    Nov 23, 2014
    Australia
    Canberra, Australia
    Thanks Cruel :-)

    I made it into a sort of incredibly crappy chat room just for fun: http://quantumc.at/websoc/
    It saves the text sent to a file and displays it in the browser and also sends it to the 3DS. I haven't actually tested it on my 3DS yet as I am in the library with wifi, that requires a sign-on page, so can't connect my 3DS to download the app. If it is broken I'll fix it in a couple of hours when home.
     
  20. DutchyDutch

    DutchyDutch COPYRIGHT LOLOLOLOL

    Member
    869
    430
    Nov 16, 2014
    Netherlands
    Could something like Pokemon Showdown work with this?