We add dozens of new titles every week including action games, sports games, hidden object and puzzle games, car, match 3, time management and racing games. As a games Mecca for games fans from all over the world, we’re pretty confident that we’re one of the biggest, best and most popular destinations for free games anywhere on the web.
WebSockets allow real-time communication between the Mobile App and the Server. You will learn the principles through a concrete example of a basic real-time multiplayers game.
Real Time Tactics (RTT) is a sub-genre of strategy games and an immensely popular one too. RTT games have always kept the spotlight and at times have shown the potential to outsell real time strategy games. BEST CHALLENGE FOR FANS OF STRATEGY GAMES & TACTICAL WARS It's a war time! It's a TIME for BATTLETIME!!! Feel like a true general of a real army. Join the battle, capture enemies’ castles and raise the power of your army. Lead your clan to the victory! In BATTLE TIME you will meet: - Plenty of maps, each of them presents a unique tactical objective - Bright, eye-catching graphics - The game. StarCraft II: Wings of Liberty (2010) StarCraft was the rival for C&C Red Alert back in 1998 and is the. Welcome to the Real-Time VFX site! If you’re a student getting into vfx, an indie dev, new enthusiast/hobbiest, or maybe a current dev looking to switch into FX, then this is the thread for you! With more and more people 48: 47847: June 12, 2020.
Difficulty: Intermediate
Forewords
Unless you are building an application that does not need to exchange information with a server, communication between a Mobile Application and a Server is a must.
HTTP Client Server
Communication between a Mobile Application and a Server is usually achieved through the HTTP protocol, where the client (= mobile app) sends a HTTP request to a Server over the Internet. Once the Server has processed the request, it returns the answer back to the client and closes the connection.
This is a one-way direction communication, where the communication must always be initiated by the client and consists in a single exchange (send -> receive -> close). The server has no possibility to send anything to the client without having been asked, by the client, to do so.
Most of the time, this means of communication is enough and even recommended. However, if you need to poll the server very frequently, move high-volume of data, react based on events that could occur at the server-side, this way of communication might become a bottleneck.
WebSockets
Some other types of applications such as chat, real-time games, auctions… may require to:
- have a communication channel that remains open between the client and the server for a longer period than a single request/response scheme
- have a bi-directional data transmission, where the server could send data to the client without having been requested/polled by the client
- support data streaming
WebSockets allow the client-side to open and persist a connection to the server.
A Web socket is a TCP socket connection between the client and the server, over the network, which allows full duplex communication, in other words: data can be transmitted in both directions and at the same time.A TCP socket is an endpoint instance, defined by an IP address and a port.
For a fully detailed documentation on the technical side of the WebSockets, please refer to RFC6455.
WebSockets in Flutter
The web_socket_channel package provides wrappers for WebSocket connections.
To install this package, add the following line to your pubspec.yaml file:
To import the package, add the following 2 imports to your .dart files:
How to connect to the Server?
To connect to the Server, you at least need to know:
- its TCP socket address (e.g. 192.168.1.25:1234)
- the name of its web sockets handler (e.g. “/svc/websockets”)
- the URL scheme (‘ws://’ for plain-text communication or ‘wss://’ for an encrypted channel)
Under the hood
This simple line sends a regular HTTP request to the Server, which also contains an “Upgrade” header to inform the Server that the client wishes to establish a WebSocket connection. This request initiates the “handshake” process.If the Server supports the WebSocket protocol, it agrees to upgrade and communicates this through an “Upgrade” header in the response. Once the handshake is complete the initial HTTP connection is replaced by a WebSocket connection that uses the same underlying TCP/IP connection.
The Channel is now open and ready to be used.
Is it safe?
Well, if you only rely on the base protocol “ws://', it is as safe as the normal “http://” protocol.
Therefore, it is strongly advised to use the same encryption as for HTTPS (TLS/SSL).
To establish such secured communication, you need:
- a SSL certificate installed on your server
- use “wss://” rather than ‘ws://’
- point to the SSL port
Extend the security by authenticating the client
As described in a previous article, you could also use the notion of “tokens', and only allow authenticated clients to connect.
Therefore, you could also pass some extra data to the header during the connection.
The following example illustrates how to pass extra data in the request header.
How to close the communication?
The communication channel may be closed by the client, using the following command:
How to send messages to the server?
How to handle communication from the server?
To be able to accept incoming messages issued by the Server, you need to subscribe (listen) to events from the Stream.
The signature is the following:
where:
- onData: method which is invoked when some data is received from the Server
- onError: method to handle any errors
- onDone: method to implement to handle a communication closure (from the Server, for example)
- cancelOnError: (default false). If set to true, the StreamSubscription is automatically closed at first error event
So, a typical implementation would be:
Let’s put all this in practice
Unlike most of the samples you may find on Internet, I am not rewriting the usual Chat application to explain this topic.Instead we are going to build the skeleton of a real-time multiplayers game. Something like a Tic-Tac-Toe game.
The example will consist in:
- A Websockets server, written in NodeJS
- A Mobile App Game where:
- Users will provide their name to join the Game;
- The list of all players will be refreshed in real-time;
- One User will select another player to start a new game;
- Both players will be simulateneously notified an brought to the Tic-Tac-Toe board game;
- Players will have the possibility to:
- Resign;
- Play and their moves will be directly visible on the other player board.
Disclaimer
This sample is only aimed at illustrating the topic. The game skeleton we are going to write is very basic, not complete and subject to huge amount of improvements, validations…
The High-Level view
At first, we need to describe the game from both client and server sides.
Client-Side
The client-side (the Mobile App itself), will consist in 2 screens.
- Screen 1:This screen will allow the user to:
- Enter a player name and join the game (= action: “join')
- See the list of all players who joined the game (= action: “players_list')
- Select a player and start a new game (= action: “new_game')Both players will then be automatically brought to the second screen.
- Screen 2:This screen will display:
- The name of the opponent player
- A resign button. If the user taps this button, the player resigns the game (= action: “resign').Both players are then brought back to the Screen 1
- A Tic-Tac-Toe grid, made up of 9 cells.
- When a player clicks on a cell of the grid, the player symbol (“X” or “O”) will be displayed on both players’ Mobile App
Server-Side
The server-side will only:
- Record the list of all players and give the players with a unique ID
- Broadcast that list to all players when a new player joins
- Record the players of new games
- Convey one player’s actions to the other game player
Communication Protocol
In order to have communication between the players and server, we need to define some kind of language. We are calling this “protocol'.
All messages that will be sent to the server or from the server to the Mobile App will follow this protocol, which consists in:
- an action
- some data
For convenience, I will use the following JSON object (= Map):
The following diagram shows the protocol:
The Server-side: WebSocket server
For this very basic WebSocket server, I opted for an implementation in NodeJS, using the “WebSocket” package.
Pre-Requisites
Real Time Game Art
In order to have this work, you need:
- to have NodeJS (version > 6) installed (refer to NodeJS Website for further details on installing NodeJS).
- install the “websocket” packageuse “npm install websocket –save” to install the package
The Source Code
The source code is this WebSocket server is very basic. Let’s first have a look at it, explanation goes along with the code.
The Client-Side: Mobile App
Now that we have the server, let’s consider the Flutter application.
The Websocket Helper
Let’s start by implementing the WebSocket Helper class.
This class is a Singleton that handles the communication based on WebSockets.
I implemented it as a Singleton in order to allow its reuse across the whole application without having to care about the connection.The simple fact of importing this .dart file, is enough to use the socket (application-level global variable).
The Game Communication Helper Class
This class is responsible for handling the websockets communication related to the game.This class is also implemented as a Singleton since it will be used by the 2 screens.
Why did I choose to implement a Game Communication Helper on top of the WebSockets Helper?
Simply because, all the logic related to the Game is centralized. Also, because if we would like to extend the game by adding some Chat feature, for example, we would only have to create a specific class which would also rely on the same WebSockets Helper.
Screen 1: Where the user joins and launches a new game
This screen is responsible for:
- Letting the user join the game, providing a name
- Maintaining a real-time list of all the players
- Letting the user start a new game with another player
Screen 2: the Game Board
This second screen is reponsible for:
- displaying the name of the opponent in the AppBar
- allowing the user to resign, via a ‘Resign’ button
- displaying the game, real-time, together with all the moves
- allowing the user to play a move and send the move to the opponent.
The main
Finally, we have the main routine that simply launches the first screen.
The results
The following video shows 2 mobile devices running this sample application.As you may see, interactions are real-time.
Conclusions
WebSockets are easy to implement and are essential when a Mobile App needs to deal with real-time and full-duplex communication.
I hope that this article demystified the concept of WebSockets through this practical example, which, once again, is only aimed at demonstrating the communication using WebSockets.
Stay tuned for new articles and, happy coding.
Real Time Tactics (RTT) is a sub-genre of strategy games and an immensely popular one too. RTT games have always kept the spotlight and at times have shown the potential to outsell real time strategy games. What makes these games so popular is the use of real-world war concepts: holding the line and executing your tactical moves to outsmart the opponent with minimum resources. We today have compiled a list of 15 best real time tactics games of all time that you shouldn’t miss if you are into strategy games:
15. UFO: Aftermath (2003)
Very few franchises have survived so long as UFO has. Since the launch of UFO: Defense, this is the first time things have gone back to basics. There are two game modes, the strategic global view, and the tactical battle view. Once the battle commences, you go into a tactical mode and need to fight the aliens with the available men, with each soldier having its own skill tree.
The game allows the player to employ a range of strategies and switches between turn-based strategy and squad-based strategy several times. Uptown pokies casino.
14. Age of Sail 2 (2001)
Given the fact that most of the wars in the late eighteenth century were fought on both land and sea, the lack of real-time naval combat games is mind-boggling. One of the very few good games in this genre is the Age of Sail 2. In the game, you get to commandeer a vessel or an entire fleet.
Your crew consists of men with various intelligence levels and their job is to fix the ship while you fight the enemy fleet and try to either sink it or force it to surrender.
13. Command & Conquer 4: Tiberian Twilight (2010)
A departure from the classic C&C formula. Tiberian Twilight takes away the base building and resource gathering and introduces pure real-time tactics gameplay along with some role-playing game elements. This means that if your units die, you can train more without penalty.
After selecting one of the two factions featured in the game, players just need to deploy a crawler and start making units in the blink of an eye (the unit count is capped). The entire focus of the game lies on capturing nodes to get points and which so ever faction controls the majority of the nodes, wins the game.
12. Syndicate: American Revolt (1993)
American Revolt is an expansion pack of the original Syndicate. The game brings the quality of the original title to a further higher standard, although the difficulty level gets really increased.
You control a gang that goes around the city killing and kidnapping people, depending on the type of mission. To my haterz. This time around there are limited ways to complete your objective, and you need to devise optimal plans to make them work.
11. Sudden Strike 2 (2002)
Sudden Strike 2 is an excellent example of how RTT games should be made. The game offers some of the finest strategy elements you would imagine in any strategy game.
You can control ground, air, and naval units for full WWII experience. But amidst all these details, the developers forgot the importance of a good user interface. The game tries to show as much of the map as possible making units very small; being RTT players, you can connect the dots now.
10. Tom Clancy’s End War (2009)
Being targeted for consoles, the gameplay has been kept relatively simple. The camera stays close to the units and you can select a number of them with a single button. To add to the ease, voice commands have been introduced which adds to the ease of play, and they work very well.
Although a good real-time tactics game, it gets its points docked on things like players’ inability to control how their battles go on the map and poor intelligence of the units.
9. Nexus: The Jupiter Incident (2004)
It is the finest space strategy game since Homeworld 2. The game puts you in command of large spaceships that you need to use to win battles of epic proportions. The animations and graphics are superb and it literally feels like watching a Star Wars film.
Although quite similar to Homeworld, the main difference in the gameplay lies in the fact that there are no resources to gather and no units to build.
8. Battlestations: Midway (2007)
Set in the late World War II era, the game takes place right along the events of Pearl Harbor. You can control battleships, fly planes and use submarines to defeat your enemy.
The multiple modes of attack along with third-person view give the game an action feel apart from its tactical gameplay, satisfying the fans of both genres. With a total of 11 campaign missions (average playtime of 4 ½ hours), the only thing disappointing about this game is its gameplay time.
7. Myth III: The Wolf Age (2001)
Although the game hardly changes anything that was introduced back in the original Myth: The Fallen Lords, but it does offer an engaging campaign, which is the real beauty of the game. Picking up from the previous games, there are no towns to manage, players just need to control the troops into battle.
Being rendered in 3D, the game allows players to outflank each other to get to higher ground for tactical advantage in a skirmish. How much money can you win at a casino.
6. Warhammer 40,000: Dawn of War II (2009)
When you expect something from the makers of Company of Heroes, you’re never disappointed. Dawn of War II gives you a team of units to command and makes sure they don’t power out during battle or you’re done (yes, your units don’t die, they power out).
The game perfectly integrates role-playing game elements, real-time tactics, and real-time strategy in an engaging story mode which can entertain a strategy gamer of any taste.
5. Commandos: Behind Enemy Lines (1998)
It is one of the finest single-player strategy games that has ever been created. In order to make something unique, you need to take risks, and that is exactly what the developers did with this game.
Commandos: Behind Enemy Lines is set in the WWII era, where each map is different and offers you something new and engaging. The gameplay and graphics are spectacular and were generations ahead of its time. The entire map is visible and the players can even track the enemy’s field of vision, all they need to do is devise a plan of action (the real birth of real-time tactics) that works.
4. Full Spectrum Warrior (2004)
This title doesn’t exactly qualify for a pure RTT or a third-person shooter game, because it lies somewhere in between. The thing about this game is that its original, it’s different and it’s good.
You get to command a squad during its operations in the Middle East, from a third-person perspective. You never actually have to aim at targets like a conventional shooter, rather order the squad which is rather unique and quite cool.
3. Sid Meier’s Gettysburg! (1997)
Based on the legendary Civil War fought on the grounds of Gettysburg in 1863, the game depicts the events of the war and beyond. Players can choose and play either Confederate or Union soldiers, and depending on the player’s progress, the game can create fictional events to proceed with the campaign.
There are a total of 25 predefined scenarios and one additional scenario that lends to endless gameplay. The beauty of this game is that no two campaign scenarios unfold the same way.
2. World in Conflict (2007)
World in Conflict is set in 1989, the cold war era. The Russians have invaded France and eventually intend to move out into the rest of Europe. You are a fresh Lieutenant named Parker, and you, along with the rest of your team will take part in the conflicts around the world to put a stop to the Soviet invasion.
The beauty of this game is that the campaign never gets repetitive. There is plenty of variety in the missions and the objectives to keep you hooked into the game for hours. The multiplayer skirmishes, maps, gameplay, tactical aids, graphics, animations, the nuclear explosions are overwhelmingly awesome. There are dozens of unofficial mods and maps for the game as well that spice up multiplayer gameplay to a further extent. It is by far one of the finest RTT games in recent years and enjoys a large fan base.
1. Total War: Shogun 2
Unsurprisingly, if we look at any online list of best real time strategy games, we will see a Total War title on the top for sure. This is because the developers know what they’re dealing with when they talk about real-time tactics games and they know exactly how to translate the word ‘perfection’ into strategy gaming.
Real-time Games Free
The game models and maps are stunningly detailed and beautifully crafted. In terms of gameplay, little has changed in Total War: Shogun 2 since Rome: Total War except for some details. But then again, something as fine as this can rock without the changes anyway.
Honorable Mentions
Our list of best real-time tactics games cannot be justified without mentioning these title too:
- Men of War (2009)
- Ground Control (2000)
- Wargame: European Escalation (2012)
Which of the above mentioned best real time tactics games do you like the most? Let us know in the comments section below!