public Server(MainForm form) { this.form = form; try { database = new Database(this); gameServers = database.GetAllGameServers(); LinkProcesses(gameServers); registrationAutomation = new RegistrationAutomation(this); form.InitializeGameServerPanel(gameServers); socketListener = new SocketListener(this, 33333); // 33333 socketListener.SocketMessageReceived += OnMessageReceive; performanceMonitor = new PerformanceMonitor(); performanceMonitor.OnPerformanceTick += OnPerformanceTick; string path = AppDomain.CurrentDomain.BaseDirectory + @"\exceptions.txt"; if(!File.Exists(path)) { File.CreateText(path); } AppDomain.CurrentDomain.UnhandledException += UnhandledException; } catch (Exception ex) { form.Output("INIT ERROR: " + ex.Message); } }
public void OnMessageReceive(SocketListener socketListener, TcpClient tcpClient, string message) { try { form.Output("OnMessageReceive: " + message); dynamic jsonObject = JsonConvert.DeserializeObject(message); string appendMessage = ProcessRequest(jsonObject); socketListener.Finalize(tcpClient, message + "<br/>" + appendMessage); } catch(Exception ex) { form.Error("OnMessageReceive:: " + ex.ToString()); } // Refresh //form.InitializeGameServerPanel(gameServers); }