/// <summary> /// Constructor /// </summary> public LogsModel() { WebCommunicator client = WebCommunicator.Instance; client.GotLogCommand += HandleLogMessage; getCurrentLog(); }
/// <summary> /// Ask for config from server /// </summary> public void getConfig() { WebCommunicator client = WebCommunicator.Instance; client.sendToServer(new TCPEventArgs((int)CommandEnum.GetConfigCommand, null)); // System.Threading.Thread.Sleep(500); //In order to show the info smoothly }
/// <summary> /// This is a top level command function. /// </summary> private async void SendMessage() { IsSending = true; OperationResultArgs CommandResult; bool isError = true; string statusText = string.Empty; if (Message.Validate()) { var Result = await WebCommunicator.Post(Message); statusText = Message.Status.Text; if (Result == HttpStatusCode.OK) { isError = false; ClearMessage(); } } else { statusText = "Invalid Message."; } CommandResult = new OperationResultArgs { IsError = isError, ResultText = statusText }; _dataRepository.AddMessage(Message); RaiseNotification(this, CommandResult); IsSending = false; }
/// <summary> /// Consturctor /// </summary> public ImageWebModel() { try { WebCommunicator client = WebCommunicator.Instance; IsConnected = client.ServiceIsOn; ImageCount = 0; Students = GetStudents(); } catch { } }
/// <summary> /// Constructor /// </summary> public ConfigModel() { try { Listhandlers = new ObservableCollection <string>(); WebCommunicator client = WebCommunicator.Instance; client.GotCloseHandlerCommand += HandleRemoveMessage; client.GotConfigCommand += HandleConfigMessage; alreadyGotConfig = false; } catch (Exception) { } }
public void Initalize() { Console.WriteLine("Initalizing server..."); Console.WriteLine("Loading server settings..."); Settings.Initalize(); Console.WriteLine("Checking file integrity..."); this.CheckFileIntegrity(); Server.ServiceLocator.RegisterService(new ScriptManager()); _netHandler = new NetHandler(Settings.GameName, Settings.ServerPort); Packet.Initalize(_netHandler); // Register the data loader factories Server.ServiceLocator.RegisterService(new FSDataFactory()); // Create and initalize the game content managers. Server.ServiceLocator.RegisterService(new ItemManager()); Server.ServiceLocator.RegisterService(new NPCManager()); Server.ServiceLocator.RegisterService(new MapManager()); Server.ServiceLocator.RegisterService(new WorldManager(_netHandler)); Server.ServiceLocator.RegisterService(new PlayerManager()); Server.ServiceLocator.RegisterService(new GameEventListener()); var pluginManager = new PluginManager(); pluginManager.Initalize(); Server.ServiceLocator.RegisterService(pluginManager); CommandHandler commandHandler = new CommandHandler(_netHandler); Server.ServiceLocator.RegisterService(commandHandler); commandHandler.Initalize(); _webCommunicator = new WebCommunicator(); //WebCommunicator.SendUDP("127.0.0.1", 41181, WebCommunicator.MessageTypes.Status_Updates, ""); }
/// <summary> /// Check for connection with service and if isn't try to connect /// </summary> public void checkConnection() { WebCommunicator client = WebCommunicator.Instance; if (client.ServiceIsOn == 0) { bool result; client.StartConnection(out result); if (result) { IsConnected = 1; } else { IsConnected = 0; } } else { IsConnected = client.ServiceIsOn; } }
/// <summary> /// Remove the handler /// </summary> /// <param name="handler">the handler to be removed</param> public void RemoveHandler(string handler) { WebCommunicator client = WebCommunicator.Instance; client.sendToServer(new TCPEventArgs((int)CommandEnum.CloseCommand, handler)); }
public void Initalize() { Console.WriteLine("Firing up engine..."); #if DEV_MODE string rootPath = AppDomain.CurrentDomain.BaseDirectory + "../../"; #else string rootPath = AppDomain.CurrentDomain.BaseDirectory; #endif Engine.Initialize(rootPath); Console.WriteLine("Initalizing server..."); Console.WriteLine("Loading server settings..."); Settings.Initalize(); Engine.Services.Get <Logger>().SuppressErrors = Settings.SuppressErrors; // Point the logger towards the current directory Engine.Services.Get <Logger>().LogPath = Constants.FILEPATH_LOGS; Engine.Services.Get <Logger>().Start(); Console.WriteLine($"Log output set to: {Engine.Services.Get<Logger>().LogPath} with error suppression {(Engine.Services.Get<Logger>().SuppressErrors ? "on" : "off")}."); Console.WriteLine("Checking file integrity..."); this.CheckFileIntegrity(); Engine.Services.Register(new ScriptManager(Constants.FILEPATH_SCRIPTS, Settings.IronPythonLibsDirectory)); var netHandler = new NetHandler(Settings.GameName, Settings.ServerPort); Engine.Services.Register(netHandler); netHandler.Initalize(); Packet.Initalize(netHandler); // Register the data loader factories IDataManagerFactory dataFactory = new FSDataFactory(); Engine.Services.RegisterAs(dataFactory, typeof(IDataManagerFactory)); dataFactory.Initalize(); // Create and initalize the game content managers. var itemManager = new ItemManager(); Engine.Services.Register(itemManager); itemManager.Initalize(); var classManager = new ClassManager(); Engine.Services.Register(classManager); classManager.Initalize(); var npcManager = new NPCManager(); Engine.Services.Register(npcManager); npcManager.Initalize(); var mapManager = new MapManager(); Engine.Services.Register(mapManager); mapManager.Initalize(); var worldManager = new WorldManager(netHandler); Engine.Services.Register(worldManager); worldManager.Initalize(); var playerManager = new PlayerManager(); Engine.Services.Register(playerManager); playerManager.Initalize(); var dialogueManager = new DialogueManager(); Engine.Services.Register(dialogueManager); dialogueManager.Initalize(); var gameEventListener = new GameEventListener(); Engine.Services.Register(gameEventListener); gameEventListener.Initalize(); var pluginManager = new PluginManager(); pluginManager.Initalize(); Engine.Services.Register(pluginManager); CommandHandler commandHandler = new CommandHandler(netHandler); Engine.Services.Register(commandHandler); commandHandler.Initalize(); _webCommunicator = new WebCommunicator(); //WebCommunicator.SendUDP("127.0.0.1", 41181, WebCommunicator.MessageTypes.Status_Updates, ""); }
/// <summary> /// Ask from server the log from the start of the service /// </summary> public void getCurrentLog() { WebCommunicator client = WebCommunicator.Instance; client.sendToServer(new TCPEventArgs((int)CommandEnum.LogCommand, null)); }
public WebCommunicator.Message SendMessage(WebCommunicator.Message outMessage) { try { WebCommunicator.Message response = communicator.SendMessage(outMessage, true); if (response == null) throw new RoomieRuntimeException("NULL response!"); if (!String.IsNullOrEmpty(response.ErrorMessage)) throw new RoomieRuntimeException("Server returned error: " + response.ErrorMessage); if (response.Values.ContainsKey("Response")) print("Server response text: " + response.Values["Response"]); else print("No server response text."); return response; } catch (CommunicationException exception) { throw new RoomieRuntimeException("WebHook Error: " + exception.Message, exception); } catch (RoomieRuntimeException exception) { throw; } catch (Exception exception) { //TODO: if (exception.Message.Equals("Thread was being aborted.", StringComparison.InvariantCultureIgnoreCase)) throw; throw new RoomieRuntimeException("REALLY unexpected error transmitting: " + exception.ToString(), exception); } }