Ejemplo n.º 1
0
        public void RegisterNewSession(SessionWrapper sessionWrapper)
        {
            var userInfo = sessionWrapper.GetUserInfo(context);

            if (isProvablyFair)
            {
                userInfo.rng.CheckOldSession();
            }

            if (sessionWrapper.UserId > 0)
            {
                reportTracker.Register(context.Game.IdLong, sessionWrapper.CasinoId, sessionWrapper.UserId);
            }

            sessionWrapper.SetUserActivityTimeout(context.Game.Id, userTimeoutInSeconds);

            if (userInfo.features.ContainsKey("time_limit"))
            {
                var startTime = userInfo.features.Evaluate <long>("time_limit_date").FromJavascriptTime();
                var timeLimit = userInfo.features.Evaluate <int>("time_limit");
                timeLimit = sessionWrapper.SetUserTimeLimit(context.Game.Id, startTime, timeLimit, userInfo.features.Evaluate("time_limit_popup", "time_limit_popup"));
                context.sendSystemInternal(sessionWrapper.SessionId, SessionMessageTypeEnum.TimeLimit, new Dictionary <string, object> {
                    { "timeLimit", Math.Max(0, timeLimit) }
                });;
            }
        }
Ejemplo n.º 2
0
        private void StorageBackgroundProc()
        {
            while (isRunning)
            {
                try
                {
                    lock (winLock)
                    {
                        foreach (var tempWinner in tempWinners.ToArray())
                        {
                            if (((DateTime)tempWinner.Value["date"]) < EnvironmentHelper.CurrentTime.Subtract(TimeSpan.FromSeconds(WINNER_AGGREGATION_PERIOD)))
                            {
                                context.sendSystemInternal(tempWinner.Key, SessionMessageTypeEnum.UserWin, new Dictionary <string, object>
                                {
                                    { "date", tempWinner.Value["date"] },
                                    { "currency", tempWinner.Value["currencyName"] },
                                    { "amount", tempWinner.Value["amount"] }
                                });

                                //context.Game.Runtime.NotifyExternalWinCallback(context.GetSession(tempWinner.Key), (DateTime)tempWinner.Value["date"], (string)tempWinner.Value["currencyName"], (decimal)tempWinner.Value["amount"]);
                                tempWinners.Remove(tempWinner.Key);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
                finally
                {
                    Thread.Sleep(5000);
                }
            }
        }
Ejemplo n.º 3
0
            public void SendInitialPackets(ScriptedGameContext scriptedGameContext, string sessionId)
            {
                var items       = CurrentVOD;
                var itemsToPlay = items?.Where(i => !i.HasEnded).ToList();

                if (itemsToPlay?.Count > 0)
                {
                    foreach (var item in itemsToPlay)
                    {
                        if (item.HasStarted)
                        {
                            item.Data["offset"] = EnvironmentHelper.CurrentTime.Subtract(item.DateStart).TotalMilliseconds - 1000;
                        }
                    }

                    var packet = new Dictionary <string, object>
                    {
                        { "vodType", (int)VodPacketTypeEnum.Play },
                        { "target", "background" },
                        { "items", itemsToPlay.Select(i => i.Data).ToArray() }
                    };

                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, packet);
                }

                var lastPacket = CurrentScreenPacket;

                if (lastPacket != null)
                {
                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, lastPacket);
                }

                var lastOverlays = Overlays.Values.ToArray();

                if (lastOverlays.Length > 0)
                {
                    var packet = new Dictionary <string, object>
                    {
                        { "vodType", (int)VodPacketTypeEnum.Play },
                        { "target", "overlay" },
                        { "items", lastOverlays }
                    };

                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, packet);
                }
            }
Ejemplo n.º 4
0
        public void RegisterSession(string sessionId)
        {
            if (streamData != null)
            {
                scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, streamData);
            }

            MediaSession session;

            lock (mediaSessionsLock)
            {
                if (!mediaSessions.ContainsKey(sessionId))
                {
                    mediaSessions[sessionId] = new MediaSession();
                }

                session = mediaSessions[sessionId];
            }

            defaultSession.SendInitialPackets(scriptedGameContext, sessionId);
            session.SendInitialPackets(scriptedGameContext, sessionId);
        }
Ejemplo n.º 5
0
        public object shuffleInternal(object source, int mode)
        {
            var sourceObject = (source as IEnumerable <object>);

            if (sourceObject == null)
            {
                throw new NullReferenceException("Object sent to shuffle is null or not an array.");
            }

            var resultArray = sourceObject.ToArray();

            if (resultArray.Length == 0)
            {
                return(resultArray);
            }

            var count = resultArray.Length - 1;
            var mt    = GameRandomHelper.GetGameRandom();

            var cycles = mt.Next(1, count);

            switch (mode)
            {
            case 0:

                for (var j = 0; j < cycles; j++)
                {
                    for (var i = 0; i < resultArray.Length; i++)
                    {
                        var index = mt.Next(0, count);
                        var temp  = resultArray[index];
                        resultArray[index] = resultArray[i];
                        resultArray[i]     = temp;
                    }
                }

                break;

            case 1:

                for (var i = 0; i < cycles; i++)
                {
                    var index = mt.Next(0, count);
                    resultArray = swapArray(resultArray, index);
                }

                break;
            }


            if (context != null && context.Game.Runtime.isProvablyFair)
            {
                if (!String.IsNullOrEmpty(sessionId) && !String.IsNullOrEmpty(finalShuffleString))
                {
                    secretPacket = new Dictionary <string, object>
                    {
                        { "hash", serverHash },
                        { "initialShuffle", initialShuffleString },
                        { "finalShuffle", finalShuffleString },
                        { "serverSeed", serverSeed },
                        { "playerSeed", playerSeed },
                    };

                    context.sendSystemInternal(sessionId, SessionMessageTypeEnum.ProvablyFairServerSecret, secretPacket);
                }

                var buffer = new byte[32];
                shuffleRandom.GetNonZeroBytes(buffer);

                finalShuffleString   = null;
                serverSeed           = BitConverter.ToString(buffer).Replace("-", String.Empty);
                initialShuffleString = resultArray.SerializeJSON().Replace("\r", String.Empty).Replace("\n", String.Empty).Replace("\t", String.Empty);
                serverHash           = String.Concat(serverSeed, initialShuffleString).ToSha256();

                if (!String.IsNullOrEmpty(sessionId))
                {
                    hashPacket = new Dictionary <string, object> {
                        { "hash", serverHash }
                    };
                    context.sendSystemInternal(sessionId, SessionMessageTypeEnum.ProvablyFairServerHash, hashPacket);
                }

                canSetPlayerSeed = true;
            }

            return(resultArray);
        }