public void Dispose() { isDisposed = true; try { Log(Id, "Shutting down game type '{0}'.", id); foreach (var scriptedGameInstance in gameInstances.ToArray()) { scriptedGameInstance.Dispose(); } var counter = 30000; while (instanceCount > 0 && counter > 0) { counter -= 50; Thread.Sleep(50); } } catch (Exception ex) { Logger.Log(ex); } finally { MonitoringFacade.UnregisterMonitoringSource(folderName); } }
public bool Initialize(IScriptedGameServerRole parent) { MonitoringFacade.RegisterMonitoringSource(id); var entryScript = entryFile.ReadAllTextFromFile(); try { using (var context = JavascriptContextFactory.Create()) { context.Run(entryScript, Path.GetFileName(entryFile)); } } catch (JavascriptException ex) { LogScriptError(entryFile, folderName, ex); return(false); } if (string.IsNullOrEmpty(id)) { throw new BusinessException("Game type cannot be empty (entry file '{0}').".FormatString(entryFile)); } gameTypeEntity = ExternalServiceFacade.GetGameCoreService().GetGameType(id); return(true); }
public void LogScriptError(string file, string instanceId, JavascriptException ex, string subSource = null) { var additionalData = new StringBuilder(); if (ex.Data.Contains("V8SourceLine")) { additionalData.Append("Source line: "); additionalData.AppendLine(ex.Data["V8SourceLine"] as string); } if (ex.Data.Contains("V8StackTrace")) { additionalData.Append("Stack trace: "); additionalData.AppendLine(ex.Data["V8StackTrace"] as string); } if (!String.IsNullOrEmpty(ex.Source)) { subSource = String.IsNullOrEmpty(subSource) ? ex.Source : "{0}/{1}".FormatString(subSource, ex.Source); } if (additionalData.Length > 0) { additionalData = additionalData.Insert(0, Environment.NewLine); } var message = "JS Error '{0}' at {1}line {2}, columns {3}:{4}.{5}".FormatString(ex.Message, String.IsNullOrEmpty(subSource) ? String.Empty : "{0}, ".FormatString(subSource), ex.Line, ex.StartColumn, ex.EndColumn, additionalData.ToString()); Logger.LogError(message, instanceId); MonitoringFacade.AddLog(instanceId, LogMessageTypeEnum.Error, message); }
public void NotifyIstanceRenamed(string oldName, ScriptedGameInstance gameInstance) { MonitoringFacade.UnregisterMonitoringSource(oldName); MonitoringFacade.RegisterMonitoringSource(gameInstance.Name); if (OnUnRegisterInstance != null) { OnUnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(oldName)); } if (OnRegisterInstance != null) { OnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(gameInstance.Id)); } }
public void NotifyIstanceAdded(ScriptedGameInstance gameInstance) { lock (instanceLock) { instanceCount++; gameInstances.Add(gameInstance); } MonitoringFacade.RegisterMonitoringSource(gameInstance.Name); if (OnRegisterInstance != null) { OnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(gameInstance.Id)); } }
public void LogError(string instanceId, string message) { Logger.LogError(message, instanceId); MonitoringFacade.AddLog(instanceId, LogMessageTypeEnum.Error, message); }
public void LogError(string instanceId, Exception ex) { Logger.Log(ex, instanceId); MonitoringFacade.AddLog(instanceId, LogMessageTypeEnum.Error, ex.Message); }
public void Log(string instanceId, string message, params object[] param) { Logger.LogWithId(message, instanceId, param); MonitoringFacade.AddLog(instanceId, LogMessageTypeEnum.Message, message.FormatString(param)); }
public void LogScriptResponse(string file, string instanceId, string message) { Logger.LogWithId(message, instanceId); MonitoringFacade.AddLog(instanceId, LogMessageTypeEnum.ScriptResponse, message); }