logo
search
SupportlaunchAPI
menulaunchSign In
close
OverviewConceptsAdmin PanelCloudAPICompliance
Overview
Get StartedAuthorizationMessagingJackpotsMultiplayerGame Client InterfaceErrors Handle
Get StartedAuthorizationGame SessionMessagingBettings and WinningsRandom Numbers GeneratorJackpotsMultiplayerTesting
Overview
Overview
Using the client libraryImplementing an integrationDeploying an integration
Replying to a gamePending Winnings
.NET CoreGoJavaNodeJsPHPPythonRuby
OverviewOverwriting jackpots
launchAPISupport
launchSign In
homeHome

Messaging

Before you begin

Before you can send a messages from Client Game to Server Game function, you need to:

  1. Create a Game inside the Fireball Admin panel
  2. Create Game Function
  3. Authorize in operator integration

Overview

Communication between any Fireball components is done by sending and receiving messages type of 'BaseMessage' class or their child. Same messages using to communicate between Game Client and Game Server Function. Any message required to have the unique Name to register the current action. Some names are taken by reserved by Fireball and can't be used (as "authenticate", "session" e.t.c.)

Prepare Custom Messages

  1. Create GameMessages.cs script with registring custom messages names as const variables:
    public class GameMessages
    {
        public const string SPIN_REQUEST = "spin-request";
        public const string SPIN_RESULT = "spin-result";

        ....

    }
  1. Create a custom messages for selected actions:
    public class SampleSpinRequest : BaseMessage
    {
        public string GameType;
        public long BetAmount;

        public SampleSpinRequest()
        {
            Name = GameMessages.SPIN_REQUEST;
        }
    }

    public class SampleSpinResult : BaseMessage
    {
        public string GameType;
        public long WinAmount;

        public SampleSpinResult(string gameType, long winAmount, BaseMessage baseMessage)
        {
            CopyBaseParams(baseMessage);

            Name = GameMessages.SPIN_RESULT;
            GameType = gameType;
            WinAmount = winAmount;
        }
    }

    ...
  1. Receive Custom Message by adding message name checking:
        public async Task<MessageResult> HandleMessage(ParseResult result)
        {
            if (result.IsSuccess)
            {
                switch (result.MessageName)
                {
                    ...

                    case GameMessages.SPIN_REQUEST:
                        return await MakeSpin(result.ToMessage<CustomSpinRequest>());

                    ...
                }
            }

            ...
        }
  1. Send Custom Message Response to the Game client with example of Fireball RNG usage (more info about RNG here):
        private async Task<MessageResult> MakeSpin(SampleSpinRequest message)
        {
            // example of custom calculation
            long winAmount = 0;
            var random = await _fireballRng.NextDouble(0, 1);
            if (random > 0.5f)
            {
                winAmount = message.BetAmount * 2;
            }

            // create a response message
            var response = new SampleSpinResult(message.GameType, winAmount, message);

            // send the response message to the game client
            return await _fireball.SendMessageToClient(response);
        }

Messages timeout

Next Steps

  • Deploy Game Function
  • Manage Game Session and game state
  • Messaging with Game client
  • Check Sample Project
Fireball logo
    HOMEABOUTPRICINGTOUR

COPYRIGHT © 2020–. ALL RIGHTS RESERVED.

v2.0.1