Game Server (Sync V2)
Game Server
Skillz provides an example game server for you to get started. If you have your own server please speak with your Skillz business contact to discuss how we can utilize your implementation. The example server is implemented in java and gives you the opportunity to customize commands and implement server side game state logic.
Communicating with the Server (Connectivity)
Connecting via SSL
The Skillz example server requires SSL. The example Unity app provides an example implementation. Cert/Public Key pinning Skillz tries to do everything possible to help our players have fair game play. As such we require our partners to pin the server certificate. Please refer to this site for a detailed explanation on cert pinning if needed.
Handling Game State
Client/Server Operation Codes
The following operation codes are used to communicate between the client and server. Op Codes sent from Server to Client: GAME_STATE_UPDATE - Sent to the client after every server tick. The tick rate is configurable, but the default value is 100 milliseconds. SUCCESS - Sent to the client after connecting to the server. MATCH_SUCCESS - Sent to the client after the player is put into a match. GAME_OVER - Sent at the end of the match Op Codes sent from the Client to Server: CONNECT - Sent to connect and join a match. PLAYER_UPDATE - Updates player game state. ABORT - Removes a player from a match. How to Send Messages (FlatBuffers) Please Note: It is strongly recommended that you read the FlatBuffer tutorial before continuing.
Why FlatBuffers
The server expects messages to be serialized using FlatBuffers. The messages will include the opcodes and any required data. You can customize the type of messages based upon what type of data you want to send. You customize your data by creating (or updating) the FlatBuffer schemas which are located in the src/flatbuffers directory of the server. For example the GameStateUpdatePacket defines a schema that contains the x and y position of the player.
Once the schema is defined you run a gradle task defined in the build.gradle which generates the source code for the client. We have added the “createFlatBuffersCPP” task which generates the C++ source code for the defined schemas. Please keep in mind that if you change the schemas you will also need to rebuild the server since the server will need the corresponding data structures which will be used when the message form the client is deserialized. Once you have the desired FlatBuffer packets defined and source generated they are easy to use.
Note:
To generate the required FlatBuffer source files use the provided gradle tasks in the build.gradle