Search code examples
javajavafxnetbeansdesktop-applicationscenebuilder

How do I implement multi-user interactions for a java-based desktop application?


I am quite new to programming so please bear with me.

For my university project, I'm developing a Java desktop app that implements a database using MySQL. For the GUI I'm using JavaFx and Scene Builder. The app I am making, is sort of inspired from certain android-based apps found on the Google playstore, namely "Life is an RPG" and "Habitica". They are sort of like "productivity" apps that help you add tasks that you want to do to the app and then reward you with in app "experience points" and "gold" on the completion of said tasks. It kind of takes old-school rpg ques and tries to organize the tasks you have to do irl in a "quest-like" manner.

That was my initial idea any ways. My instructor wanted me to add some functionalities. Namely, he wanted users of my app to be able to form "groups" or "parties" with each other and engage in a sort of group activity, where they are all doing the same activity, and hence, being rewarded for said activity.

Upon scouring through tutorials, I managed to find out and implement the basic functionalities of the app, say logging in of a user or the adding of tasks, etc. However, what I am failing to figure out is how I can make this user to user interaction happen within the app. I'm sorry if my problem sounds a bit too broad to ask, but I have been looking it up and I'm failing to understand or come up with ideas on how I can tell my program that User A is interacting with User B, and that they are working together to complete a certain task.

I apologize once again for the rather silly problem and long wall of text. Some help or clarity in this regard would be highly appreciated. Even a point in the right direction in regards to what I need to research on and learn would be a great help.

Thank you.


Solution

  • Since this is very broad I am going to give you high-level answer. The individual desktop clients all share the same database (MySQL).

    Therefore, you can solve this problem there: in your database.

    One option would be to have a some kind of "group task". Every user of your app can sign up for this task and when it is "completed", everyone earns some points.

    To manage this you could have to tables in your database:

    • One table for the tasks
    • One table for collaborators

    Every task needs a unique id that you then can reference in your collaborators table.

    Task table:
    
    -------------------------
    | ID | Task             |
    =========================
    | 1  | Slay dragon      |
    -------------------------
    
    Collaborators table:
    -------------------------
    | Task | User           |
    =========================
    | 1    | Moe            |
    -------------------------
    | 1    | Homer          |
    -------------------------
    

    In this example Moe and Homer have the task to slay a dragon. Once the dragon is dead both can get some points. This is a very, very simple example. Usually, you would have more tables. At least one for the users etc.

    But other than that this would be the high-level idea. Obviously, you will need to build some UI to allow users to participate in tasks etc. But I am sure you can figure that out.