public void disableInstance(string message, int reason) { if (!isDisabled || currentDisableReason != reason) { context.Game.Log("Disabling the instance with message: {0}", message); isDisabled = true; currentDisableReason = reason; var parameters = new Dictionary <string, object> { { "reason", reason } }; if (reason == 2) { try { var info = BaseExternalGameInfoService.Gateway.GetOfflineGameInfo(context.Game.Id, 0, 0, 0); var offlineImage = info.Evaluate <string>(BaseExternalGameInfoService.OFFLINE_IMAGE); if (!String.IsNullOrEmpty(offlineImage)) { parameters[BaseExternalGameInfoService.OFFLINE_IMAGE] = offlineImage.FixUrl(true); } } catch (Exception exx) { Logger.Log(exx); } } context.accountingHelper.CancelCurrentBets(null, "instance is disabled"); SendServerMessage(ServerMessageTypeEnum.disable_instance, parameters); context.sendSystemAllInternal(SessionMessageTypeEnum.Disable, parameters); context.Game.UpdateGameState(GameStateEnum.Disabled, "Instance is disabled", null); } }
public void cancelRound(string roundId, string cancelBets, object successCallback, object failureCallback) { Task.Run(() => { try { var roundIdLong = roundId.ToLong(); var cancelBetsBool = cancelBets.ToBool(); if (roundIdLong == context.roundCounter.current) { userBetStores.Clear(); betUsers.Clear(); tempUsers.Clear(); } accountingFacade.CancelRound(context.Game.IdLong, roundIdLong, cancelBetsBool); if (roundIdLong == context.roundCounter.current) { foreach (var userInfo in context.sessions.Select(context.getUserInfo)) { userInfo.RefreshBalance(); SendBalanceChanged(userInfo.sessionId, userInfo.Balance, userInfo.totalLoss); } } context.sendSystemAllInternal(SessionMessageTypeEnum.RoundCancel, new Dictionary <string, object> { { "roundId", roundId } }); context.Game.ExecuteCallback(this, successCallback, false); } catch (Exception ex) { context.Game.LogError(ex); try { context.Game.ExecuteCallback(this, failureCallback, false); } catch (Exception exx) { context.Game.LogError(exx); } } }); }
public void showOverlay(string sessionId, object overlay) { var hasEmptySession = String.IsNullOrEmpty(sessionId) || sessionId.EqName("0"); var items = new List <IDictionary <string, object> >(); var item = overlay as IDictionary <string, object>; string name = null; if (item != null) { if (!item.ContainsKey("name") || item["name"] == null) { throw new Exception("Required field 'name' is not provided"); } name = item["name"].ToString(); } else { name = overlay.ToString(); item = new Dictionary <string, object> { { "name", name } }; } if (overlayMap != null) { var path = name.Replace('\\', '/'); while (!String.IsNullOrEmpty(path)) { if (overlayMap.ContainsKey(path)) { var overlayItem = overlayMap[path] as IDictionary <string, object>; if (overlayItem != null) { foreach (var configItem in overlayItem) { if (!item.ContainsKey(configItem.Key)) { switch (configItem.Key) { case "path": var nameOnly = Path.GetFileName(name); var fullPath = configItem.Value.ToString().Replace('\\', '/').TrimEnd('/').ConcatString("/", nameOnly); item[configItem.Key] = fullPath; break; case "overlayType": switch (configItem.Value.ToString().ToLower()) { case "media": break; case "winners": item["items"] = scriptedGameContext.storageHelper.GetLastWinners(); break; } break; default: item[configItem.Key] = configItem.Value; break; } } } } break; } path = (Path.GetDirectoryName(path) ?? String.Empty).Replace('\\', '/'); } } if (!item.ContainsKey("overlayType")) { item["overlayType"] = "media"; } items.Add(item); var packet = new Dictionary <string, object> { { "vodType", (int)VodPacketTypeEnum.Play }, { "target", "overlay" }, { "items", items.ToArray() } }; var session = GetMediaSession(sessionId); if (session != null) { var overlays = session.Overlays; if (overlays.Count > MAX_OVERLAYS_HISTORY) { overlays.Clear(); } overlays[name] = item; } if (hasEmptySession) { scriptedGameContext.sendSystemAllInternal(SessionMessageTypeEnum.VOD, packet); } else { scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, packet); } }