Post

GSoC Phase 2

GSoC Phase 2

GSoC 2025: Part 2 – The Final Phase

Alright, so now that I’m at the end of GSoC 2025, I’ll cover what I’ve done during the second phase (post-midterm).

Now that the offline part of the app is complete, I focused my work on the online multiplayer functionality. I used XMPP for this because it provides a lot of functionality out of the box.


Login Feature

The first step was implementing the login system. I looked into several examples, including QXmpp, Kaidan, and other open-source projects.
While QXmpp handles the actual login, I didn’t want users to have to log in every time they opened the app — credentials had to be stored securely somewhere.

The requirement was to use a component supported on both Linux and Android. It came down to Qt Keychain and QSettings. Keychain is definitely the more secure approach, but for now, I chose QSettings since it’s hassle-free and simple.
Now, the credentials are stored in a file when updated, and automatically loaded on app startup.


Game Session Initialization

The next step was to initialize a game session. I explored quite a few approaches to achieve this.
The main questions were:

  • Should I allow inviting a player when they’re offline?
  • How do I handle the handshake?
  • What message type should I use?

I experimented with several message types — Normal, Chat, and even Headline. I also tried using IQ stanzas, and at one point, even wrote my own QXmppClient extension (which I eventually removed).

Finally, I decided to stick with Normal-type messages. The main advantage is that normal messages don’t get rendered in regular XMPP clients. This means the game invites won’t interfere with the chat experience if the same account is used for both chatting and playing.

I faced a few challenges here and even implemented a receipt manager at one point. The final flow looks something like this:

(I will attach an image here later.)


Game Room and Communication

Once the game handshake was complete, I needed a way for players to communicate moves — essentially, a game room.

I explored multiple ideas and did some research:

  • Using one-to-one messaging
  • Creating and joining a MUC (Multi-User Chat)
  • Using PubSub

Initially, I tried the PubSub approach and even got the handshake working. But it felt like overkill, as both players needed publishing permissions and additional management logic.

So, I switched to the MUC approach. Once the handshake is done, players create or join a MUC — this information is shared through the game invite.
Next, I modified the GameWindow to support this system. Initially, it worked only on a single device, so I had to generalize the logic to handle multiple clients properly — and it worked!

While it’s not yet a fully featured multiplayer experience, it provides the base functionality and a smooth user experience.


Challenges Faced

1. Lack of QXmpp Code Examples

My primary challenge was finding proper code examples and documentation for QXmpp. It took a fair bit of time and experimentation.

2. Echoed Messages

Another challenge I encountered was message echoing — sometimes the messages I sent came back to me. The metadata (like message ID) remained the same, but the from and to fields were swapped.
This usually happened when the recipient was offline or nonexistent, but occasionally even when they were online.

I found a related question on StackOverflow:
https://stackoverflow.com/questions/24818062/sent-messages-coming-back-in-xmpp

Although I didn’t find an official fix, I created a workaround:
I stored the IDs of sent messages, and whenever a message arrived, I checked if its ID had already been sent. If yes, I rejected it.

3. Other Small Challenges

  • At one point, I thought there was an issue with MankalaEngine while exporting Pallanguli, but it turned out I had just missed including a header file.
  • Another time, I was using different instances of a class across screens and was wondering why data wasn’t shared — rookie mistake, but a good learning moment!

Conclusion

Overall, my GSoC experience was amazing and provided an incredible learning journey.
My mentor, Benson Muite, was extremely supportive — always pointing me in the right direction when I was stuck and giving thoughtful, constructive feedback on my contributions.

This program truly opened up a whole new world of opportunities and introduced me to a vibrant, welcoming community. I’m incredibly grateful to have been part of it.


This post is licensed under CC BY 4.0 by the author.