UI apps networking?

Discussion in 'Programming' started by gigawert, Jul 19, 2017.

  1. StinchinStein

    StinchinStein
    Expand Collapse

    Joined:
    Jul 16, 2014
    Messages:
    754
    You could always use the Lua side to write the files, then maybe make an external program to upload it to the site you're making. That way the networking is completely separate from the BeamNG.drive Sandbox.

    As far as I know he'd have to get it himself, pretty sure it isn't included.

    Edit: Ninja'd
     
  2. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Yes, you just got ninja'd. Anyway I'll have to see about learning Lua.
     
  3. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    3,030
    The lua is also sandboxed. All I/O is sandboxed. You should not be able to read any system files, and writing is only allowed to our special write-out path. That is a security measurement to protect users against malicious mods.
     
    • Like Like x 2
  4. EruptionTyphlosion

    EruptionTyphlosion
    Expand Collapse

    Joined:
    Sep 24, 2016
    Messages:
    2,927
    So I'm assuming only devs can edit those files. Wait, sorry if I sound dumb, what does sandboxed mean? Does it mean that it's restricted and locked to a users PC?
     
  5. StarredKing101

    StarredKing101
    Expand Collapse

    Joined:
    May 17, 2017
    Messages:
    151
    A sandbox is a testing environment that isolates untested code changes and outright experimentation from the production environment or repository, in the context of software development including Web development and revision control.

    That's from wikipedia
     
    • Informative Informative x 2
  6. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    So I can read/write files within Documents/BeamNG? If so, that's fine.
     
    • Like Like x 1
  7. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    I have a recommendation. You're not going to be able to do what you want through BeamNG. I suggest you write a separate client for your project. It'll act as a middleman between a user's BeamNG docs file, and your web server. You can have it have info files for a UI app to read, as well, so that you can have whatever you want shown in the UI dumped into the info files by your client. This will not be a small project, by any means.
     
    • Like Like x 1
    • Agree Agree x 1
  8. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Yeah that would be the only way...
     
    #28 gigawert, Jul 30, 2017
    Last edited: Jul 31, 2017
  9. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
  10. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    C# probably.
     
    • Informative Informative x 1
  11. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Can the UI app write to files within Documents\BeamNG.drive?
     
  12. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Actually, can the UI app communicate with the program I'm going to make in C# or is there some way for the program to go to the UI app and retrieve data every so often?
    --- Post updated ---
    I've decided to write it with C++ instead as I already have a bit of experience with that and the C# tutorials out there seem to be outdated, even the Hello World example is broken.
     
    • Agree Agree x 1
  13. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Uh oh, I've run into an obstacle. Because of a header file that's part of the MySQL library, mysql_connection.h in particular, it won't compile because "error: expected class name before '{' token". I'm not entirely sure how exactly to fix this.
     
  14. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    as @Funky7Monkey said you have to use a middle man to transfert data.

    I think you should write a LUA module which will be able to write to the /documents/BNG and also chat with your middleware thanks to a localhost connection.
    So you program in C++ or other can send those files back to your website.

    mySQL should be on the server so you don't need to compile it in your middleware? the only thing you need is http client library like CURL. If you really want to save some data you can use something like sqlite

    Small recommendation : release your program as open source, I wouldn't trust anything else because your middleware can do what ever it wants.
     
    • Agree Agree x 1
  15. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    Well, I need the MySQL Connector (distributed as header files) to connect to my database, there doesn't seem to be another way. https://dev.mysql.com/doc/connector-cpp/en/

    While I would like to release it as open source, the database usernames and passwords would be revealed in the source code... so I couldn't do that.

    Also, how exactly would the user activate the ingame LUA module?
     
    #35 gigawert, Aug 6, 2017
    Last edited: Aug 6, 2017
  16. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    Use tokens.

    As I said before, this will be a massive project.
     
  17. gigawert

    gigawert
    Expand Collapse

    Joined:
    Sep 6, 2015
    Messages:
    2,029
    It is somewhat massive but I already have the whole website laid out including the databases and server side programming. I'm trying to code the client software now though.
     
    #37 gigawert, Aug 7, 2017
    Last edited: Aug 7, 2017
  18. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Having looked at it, and being a C#developer for a living. Nothing wrong with the tutorial.
     
  19. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    You should not have a direct connection between any client and your server using mysql, as you said it can reveal some bad stuff, but you will have to put the database password inside the app, this could lead someone to recover it and dump or drop your whole server.

    What you need to do is use your website as an api. This way your website/api will validate every input.
    Code:
    bngsell.net/api/sellCar?iduser=42&car=1
    You can start the game and say to the game to load a module when the map is loaded. (I will give you the command line argument when i'm at work)

    Code:
     -onLevelLoad_ext 'util/createThumbnails'
    the draw back is the module will be unloaded when you change map. You can load it back if you write a small ingame APP if you want to display information
     
    #39 thomatoes50, Aug 7, 2017
    Last edited: Aug 7, 2017
  20. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    Unfortunately, @gigawert, I think you're going to have to deal with login stuff, both on the website and in the client program. Please do it securely, and correctly. And damn it, if you store passwords in plain text, or have user IDs not randomized, I will personally strangle you.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice