Beispiel #1
0
        private void crashBtn_Click(object sender, EventArgs e)
        {
            if (serverListBox.SelectedItem == null || serverListBox.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Must select a server from the list.");
                return;
            }

            string serverID = serverListBox.SelectedItem.ToString();

            IServerPM server = Program.GetServer(serverID);

            if (server == null)
            {
                MessageBox.Show($"Server '{serverID}' is disconnected.");
                Program.RemoveServerFromList(serverID);
                return;
            }

            try
            {
                server.Crash();
            }
            catch (System.Net.Sockets.SocketException)
            {
                MessageBox.Show($"Server '{serverID}' has been crashed.");
                Program.RemoveServerFromList(serverID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #2
0
        public void ExecCommands()
        {
            foreach (var command in commands)
            {
                MessageBox.Show("PM Will Execute... " + command[0]);

                if (command[0].Equals("crash", StringComparison.OrdinalIgnoreCase))
                {
                    IServerPM server = Program.GetServer(command[1]);

                    try
                    {
                        server.Crash();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //return;
                    }
                }
                else if (command[0].Equals("freeze", StringComparison.OrdinalIgnoreCase))
                {
                    IServerPM server = Program.GetServer(command[1]);

                    try
                    {
                        server.Freeze();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //return;
                    }
                }
                else if (command[0].Equals("unfreeze", StringComparison.OrdinalIgnoreCase))
                {
                    IServerPM server = Program.GetServer(command[1]);

                    try
                    {
                        server.Unfreeze();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //return;
                    }
                }
                else if (command[0].Equals("wait", StringComparison.OrdinalIgnoreCase))
                {
                    Utilities.Wait(Int32.Parse(command[1]));
                }
                else if (command[0].Equals("status", StringComparison.OrdinalIgnoreCase))
                {
                    Program.PrintStatus();
                }
                else if (command[0].Equals("server", StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        Program.CreateServer(command[1], RemotingAddress.FromString(command[2]),
                                             Convert.ToUInt32(command[3]), Convert.ToUInt32(command[4]), Convert.ToUInt32(command[5]));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"Error creating server: {ex.Message}",
                                        "Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        //return;
                    }
                }
                else if (command[0].Equals("client", StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        Program.CreateClient(command[1], RemotingAddress.FromString(command[2]),
                                             RemotingAddress.FromString(command[3]), command[4]);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"Error creating client: {ex.Message}",
                                        "Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        //return;
                    }
                }
                else if (command[0].Equals("AddRoom", StringComparison.OrdinalIgnoreCase))
                {
                    if (Program.serverList.Count == 0)
                    {
                        MessageBox.Show($"Cannot add room '{command[3]}' because there are no servers running.",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;//return;
                    }

                    try
                    {
                        Program.serverList[0].Item3.AddRoom(command[1], Convert.ToUInt32(command[2]), command[3]);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //return;
                    }
                }

                foreach (string s in command)
                {
                    Utilities.WriteDebug(s + " ");
                }
                Console.Write("\r\n");

                //MessageBox.Show("PM Executed: " + command[0]);
            }
        }