The iTavli application supports Online Gaming for more than 5 years now. During this time period many things have changed, but our philosophy for online gaming stays the same: We give full control to a user on the game. Thus, a user is allowed to select the opponent and the game that (s)he wishes to play. Respectively, the tentatively opponent is allowed to accept that invitation, and start the game, or reject it.
In order to make online gaming a little more interesting, a user could mark a player as buddy. Then, when that player was online, the user would receive a notification. Finally, a user could invite his/her FB friends to a game. But..
As with the iTavli application, the code for the online game is being updated. We receive feedback from our users and we implement the features that are requested. Now, we are in the third major update, and in this article we want to describe what is changed in that version.
Writing a code for online game is a fairly complicated task. We do not want to get into details, but, it is not as easy as is to code for a Local game. Everyone who is working on such project needs to address the following issues:
- Monitor when a player is online
- Send invitation to a player for a game
- Accept or Reject that invitation
- Start a game
We tackle these issues with the use of a Server. All users who want to play an online game need first to connect to that Server. Then, we write the code for that server so that it handles all incoming requests. Note: A user is marked as offline when (s)he is disconnected from the server.
In the first version of our online game we decided to write the code for the server. Even though this code was working well, it did not scale well. As the number of online players was increasing, our code could not cope with the increasing number of requests. We soon had to look for an alternative. Thus, we released the second version.
In the second version we used a 3rd party library. For obvious reasons we do not want to mention the name of that company. We updated our online code so that it was compatible with that new library. Note, that the only thing that we needed to change was the code that interacts with the Server. The remaining code was the same, and it still is.
For about a year we were really content with that library, but then iOS 13 was released. This library did not work well with the iOS 13 version, and even though we reported that problem to the developers of the company, they were not eager to fix it. Thus, we had to make a new release.
We searched the Internet and we found another library that works on all iOS and Android versions. Thus, we modified the online code one more time, and in late October 2019 we released a version with the new online code.
This new library, however, has a different logic than the previous one. It gives us more freedom to handle certain tasks, but, then again, it is far more complicated to code for them. Yet, in mid November 2019, we released a new 3rd version (version 2.0) for both devices.
Because we fixed so many things in version 2.0 we did not want our players to play an online game against players who had the previous version (version 1.0). Thus, we made those two versions incompatible, and a user could play an online game only against a player who runs the same version.
Since version 2.0 is by far the best version for the online code that we had, we list here the new features of this version:
- Highlight with red color an offline player. The color is orange again when the player is back online
- Double check the game moves so that no move is lost when a player is offline
- A user can terminate the game if (s)he ends her/his turn but the opponent is offline. There is a timer, and when the time has elapsed, a message appears prompting the user to end the game, because the opponent may have abandoned the game
This new library is not used on the Web version of the iTavli app. We apologize for this, and we will try to implement it as soon as possible. We currently want to address a few minor issues that we have found in the mobile version.
Enjoy the game